21 March

Linux filesystem tools

For this tutorial, you’ll need a few additional tools on your Debian VM. Make sure you are connected to the Internet, and try this (you’ll need your password, LIUcs!@

liucs:~$ sudo apt-get install parted lvm2

GNU Parted is a command-line partition editor, and LVM is the Logical Volume Manager.

Installing disks

Now we’ll create extra (virtual) disks that we can use with the VM. Shut down your VM using the “exit” icon in the lower right.

Go into the VM settings, in the storage section.

Here’s a storage tree with three new hard disks:

Partitioning

Boot up your Debian VM again. In a terminal, let’s become the super-user, because most everything we’ll be doing from here requires “root” access. You’ll know you are root by the pound sign after the prompt:

liucs:~$ sudo -s
root@liucs:/home/liucs#

If you get a listing of the device files starting with sd, you’ll see all the attached disks and their partitions:

root@liucs:/home/liucs# ls -l /dev/sd*
brw-rw---- 1 root disk 8,  0 Mar 21 17:45 /dev/sda
brw-rw---- 1 root disk 8,  1 Mar 21 17:45 /dev/sda1
brw-rw---- 1 root disk 8,  2 Mar 21 17:45 /dev/sda2
brw-rw---- 1 root disk 8,  5 Mar 21 17:45 /dev/sda5
brw-rw---- 1 root disk 8, 16 Mar 21 17:45 /dev/sdb
brw-rw---- 1 root disk 8, 32 Mar 21 17:45 /dev/sdc
brw-rw---- 1 root disk 8, 48 Mar 21 17:45 /dev/sdd

In Linux, sda refers to the first SCSI/SATA hard disk, and these three sdb, sdc, and sdd are the new ones you just added.

When there is a number after the disk ID, it refers to the partition. So the entire disk sda is split up into three segments, called sda1, sda2, and sda5.

Let’s use parted to get information about the partition table on sda:

root@liucs:/home/liucs# parted /dev/sda print
Model: ATA VBOX HARDDISK (scsi)
Disk /dev/sda: 8590MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start   End     Size    Type      File system     Flags
 1      1049kB  8186MB  8185MB  primary   ext3            boot
 2      8187MB  8589MB  402MB   extended
 5      8187MB  8589MB  402MB   logical   linux-swap(v1)

We can see here that the partition 1 (sda1) is used for the main Linux filesystem on this machine. Its filesystem type is ext3. The partition 5 (sda5) is used as swap space, for virtual memory. Partition 2 is really just a legacy of how this old MS-DOS partition table works: you can see that its start and end points overlap that of sda5.

Now we’ll create a partition table on the second disk, sdb, and split its available space in half.

parted /dev/sdb mkpart primary ext3 0% 50% mkpart primary ext3 50% 100%

Formatting

Mounting

Logical volumes

comments powered by Disqus

 

©2012 Christopher League · some rights reserved · CC by-sa