L. J. Jaeckel                      ◄ Home        ◄ Back to Mid-Term Debian log
CMPSC 210 – Linux System Administration
February 27, 2011

MID-TERM: Transcript showing creation of a second
virtual hard disk drive in the debian5vm machine

Note: This transcript is edited to make it more readable, and to make it an HTML page:

Nevertheless, I, Jay Jaeckel, hereby certify that this transcript, as shown here, substantially and correctly shows what actually happened.

First things first: Creating the virtual disk in VMware.

Here are the detailed steps running the Add Hardware Wizard:

Now, boot up the Virtual Machine

Log in (as user jeremy).
Start a terminal window.
Before doing any work with the new disk, first examine the state of some things so far.
Note that none of the following commands show any mention of /dev/sdb (yet):

    jeremy@debian5vm: /home/jeremy $ df
    Filesystem           1K-blocks      Used Available Use% Mounted on
    /dev/sda1              2395540   1688872    584980  75% /
    tmpfs                   258148         0    258148   0% /lib/init/rw
    udev                     10240       688      9552   7% /dev
    tmpfs                   258148         0    258148   0% /dev/shm
    /dev/sda6              5534416    143572   5109712   3% /home


jeremy@debian5vm: /home/jeremy $ mount /dev/sda1 on / type ext3 (rw,errors=remount-ro) tmpfs on /lib/init/rw type tmpfs (rw,nosuid,mode=0755) proc on /proc type proc (rw,noexec,nosuid,nodev) sysfs on /sys type sysfs (rw,noexec,nosuid,nodev) procbususb on /proc/bus/usb type usbfs (rw) udev on /dev type tmpfs (rw,mode=0755) tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev) devpts on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=620) /dev/sda6 on /home type ext3 (rw) none on /proc/fs/vmblock/mountPoint type vmblock (rw)
jeremy@debian5vm: /home/jeremy $ /sbin/swapon -s Filename Type Size Used Priority /dev/sda5 partition 329292 0 -1
jeremy@debian5vm: /home/jeremy $ cat /etc/fstab # /etc/fstab: static file system information. # # <file system> <mount point> <type> <options> <dump> <pass> proc /proc proc defaults 0 0 /dev/sda1 / ext3 errors=remount-ro 0 1 /dev/sda6 /home ext3 defaults 0 2 /dev/sda5 none swap sw 0 0 /dev/hdc /media/cdrom0 udf,iso9660 user,noauto 0 0 /dev/fd0 /media/floppy0 auto rw,user,noauto 0 0

Begin partitioning the new disk and creating the file system on one partition and swap area on another.
Do all this as root user.

    jeremy@debian5vm: /home/jeremy $ su -
    Password:        

    (SUPER-USER!) root@debian5vm: /root #


First, observe that fdisk sees that the new disk /dev/sdb is there and its geometry is known, but it is not partitioned:

    (SUPER-USER!) root@debian5vm: /root # fdisk -l

    Disk /dev/sda: 15.0 GB, 15032385536 bytes
    255 heads, 63 sectors/track, 1827 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes
    Disk identifier: 0x0002ee7c

       Device Boot      Start         End      Blocks   Id  System
    /dev/sda1   *           1         303     2433816   83  Linux
    /dev/sda2             304        1044     5952082+   5  Extended
    /dev/sda5             304         344      329301   82  Linux swap / Solaris
    /dev/sda6             345        1044     5622718+  83  Linux

    Disk /dev/sdb: 2147 MB, 2147483648 bytes              
    255 heads, 63 sectors/track, 261 cylinders            
    Units = cylinders of 16065 * 512 = 8225280 bytes      
    Disk identifier: 0x00000000                           
                                                          
    Disk /dev/sdb doesn't contain a valid partition table.


Note the /dev directory already has sdb, but no sdb1 or sdb2 — Will these get created automatically somewhere along the way, or will I have to create them manually?

    (SUPER-USER!) root@debian5vm: /root # ls -al /dev/sd*
    brw-rw---- 1 root disk 8,  0 2011-02-27 21:35 /dev/sda
    brw-rw---- 1 root disk 8,  1 2011-02-27 21:35 /dev/sda1
    brw-rw---- 1 root disk 8,  2 2011-02-27 21:35 /dev/sda2
    brw-rw---- 1 root disk 8,  5 2011-02-27 21:35 /dev/sda5
    brw-rw---- 1 root disk 8,  6 2011-02-27 21:36 /dev/sda6
    brw-rw---- 1 root disk 8, 16 2011-02-27 21:35 /dev/sdb


Begin fdisk to create the partitions on /dev/sdb — I am using fdisk rather than cfdisk because it is easier to make a transcript of the session:

    (SUPER-USER!) root@debian5vm: /root # fdisk /dev/sdb
    Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
    Building a new DOS disklabel with disk identifier 0x22f1f1ee.
    Changes will remain in memory only, until you decide to write them.
    After that, of course, the previous content won't be recoverable.

    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

    Command (m for help): m
    Command action
       a   toggle a bootable flag
       b   edit bsd disklabel
       c   toggle the dos compatibility flag
       d   delete a partition
       l   list known partition types
       m   print this menu
       n   add a new partition
       o   create a new empty DOS partition table
       p   print the partition table
       q   quit without saving changes
       s   create a new empty Sun disklabel
       t   change a partition's system id
       u   change display/entry units
       v   verify the partition table
       w   write table to disk and exit
       x   extra functionality (experts only)

Create the first partition, /dev/sdb1 to be the swap area. The size of 130 cylinders is chosen to be about half the total available space of 261 cylinders:

    Command (m for help): n
    Command action
       e   extended
       p   primary partition (1-4)
    p
    Partition number (1-4): 1
    First cylinder (1-261, default 1): 1
    Last cylinder or +size or +sizeM or +sizeK (1-261, default 261): 130

    Command (m for help): p

    Disk /dev/sdb: 2147 MB, 2147483648 bytes
    255 heads, 63 sectors/track, 261 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes
    Disk identifier: 0x0d3badfa

       Device Boot      Start         End      Blocks   Id  System
    /dev/sdb1               1         130     1044193+  83  Linux

Note, the partition was created as a data (type 83) partition. Now change it to a swap (type 82) partition:

    Command (m for help): t
    Selected partition 1
    Hex code (type L to list codes): 82
    Changed system type of partition 1 to 82 (Linux swap / Solaris)

    Command (m for help): p

    Disk /dev/sdb: 2147 MB, 2147483648 bytes
    255 heads, 63 sectors/track, 261 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes
    Disk identifier: 0x0d3badfa

       Device Boot      Start         End      Blocks   Id  System
    /dev/sdb1               1         130     1044193+  82  Linux swap / Solaris

Create the second partition, /dev/sdb2 to be a data file system. The size is chosen to take up the remainder of the disk:

    Command (m for help): n
    Command action
       e   extended
       p   primary partition (1-4)
    p
    Partition number (1-4): 2
    First cylinder (131-261, default 131): 131
    Last cylinder or +size or +sizeM or +sizeK (131-261, default 261): 261

    Command (m for help): p

    Disk /dev/sdb: 2147 MB, 2147483648 bytes
    255 heads, 63 sectors/track, 261 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes
    Disk identifier: 0x0d3badfa

       Device Boot      Start         End      Blocks   Id  System
    /dev/sdb1               1         130     1044193+  82  Linux swap / Solaris
    /dev/sdb2             131         261     1052257+  83  Linux

Write the partition table to the disk, and exit:

    Command (m for help): w
    The partition table has been altered!

    Calling ioctl() to re-read partition table.
    Syncing disks.


Now fdisk -l sees the partitions on the new disk. (Compare with the fdisk -l done earlier.)

    (SUPER-USER!) root@debian5vm: /root # fdisk -l

    Disk /dev/sda: 15.0 GB, 15032385536 bytes
    255 heads, 63 sectors/track, 1827 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes
    Disk identifier: 0x0002ee7c

       Device Boot      Start         End      Blocks   Id  System
    /dev/sda1   *           1         303     2433816   83  Linux
    /dev/sda2             304        1044     5952082+   5  Extended
    /dev/sda5             304         344      329301   82  Linux swap / Solaris
    /dev/sda6             345        1044     5622718+  83  Linux

    Disk /dev/sdb: 2147 MB, 2147483648 bytes                                     
    255 heads, 63 sectors/track, 261 cylinders                                   
    Units = cylinders of 16065 * 512 = 8225280 bytes                             
    Disk identifier: 0x0d3badfa                                                  
                                                                                 
       Device Boot      Start         End      Blocks   Id  System               
    /dev/sdb1               1         130     1044193+  82  Linux swap / Solaris 
    /dev/sdb2             131         261     1052257+  83  Linux                


The cfdisk program has options to display the partition table in a variety of different formats, including by sectors and even a raw hex dump. Here is what some of these listings look like:

    (SUPER-USER!) root@debian5vm: /root # cfdisk /dev/sdb

                            cfdisk (util-linux-ng 2.13.1.1)

                                  Disk Drive: /dev/sdb
                            Size: 2147483648 bytes, 2147 MB
                  Heads: 255   Sectors per Track: 63   Cylinders: 261

        Name        Flags      Part Type  FS Type          [Label]        Size (MB)
     ------------------------------------------------------------------------------
        sdb1                    Primary   Linux swap / Solaris              1069.29
        sdb2                    Primary   Linux                             1077.52

Partition table displayed in "Table" format:

    Partition Table for /dev/sdb

             ---Starting---      ----Ending----    Start     Number of
     # Flags Head Sect Cyl   ID  Head Sect Cyl     Sector    Sectors
    -- ----- ---- ---- ---- ---- ---- ---- ---- ----------- -----------
     1  0x00    1    1    0 0x82  254   63  129          63     2088387
     2  0x00    0    1  130 0x83  254   63  260     2088450     2104515
     3  0x00    0    0    0 0x00    0    0    0           0           0
     4  0x00    0    0    0 0x00    0    0    0           0           0

Partition table displayed in "Sector" format:

    Partition Table for /dev/sdb

                   First       Last
     # Type       Sector      Sector   Offset    Length   Filesystem Type (ID) Flag
    -- ------- ----------- ----------- ------ ----------- -------------------- ----
     1 Primary           0     2088449     63     2088450 Linux swap / So (82) None
     2 Primary     2088450     4192964      0     2104515 Linux (83)           None

Partition table displayed in "Raw" (Hex dump) format
(This is a dump of Sector 0 of the disk — the partition data is near the end of this):

    Disk Drive: /dev/sdb
    Sector 0:
    0x000: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x010: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x020: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x030: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x040: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x050: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x060: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x070: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x090: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0A0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0B0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0C0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0D0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0E0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0F0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x100: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x110: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x120: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x130: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x140: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x150: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x160: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x170: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x180: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x190: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x1A0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x1B0: 00 00 00 00 00 00 00 00 FA AD 3B 0D 00 00 00 01
    0x1C0: 01 00 82 FE 3F 81 3F 00 00 00 C3 DD 1F 00 00 00
    0x1D0: 01 82 83 FE 7F 04 02 DE 1F 00 C3 1C 20 00 00 00
    0x1E0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x1F0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 AA



Having created the partitions, now we are ready to create the ext3 file system on the second partition, /dev/sdb2

    (SUPER-USER!) root@debian5vm: /mnt # mkfs.ext3 /dev/sdb2
    mke2fs 1.41.3 (12-Oct-2008)
    Filesystem label=
    OS type: Linux
    Block size=4096 (log=2)
    Fragment size=4096 (log=2)
    65808 inodes, 263064 blocks
    13153 blocks (5.00%) reserved for the super user
    First data block=0
    Maximum filesystem blocks=272629760
    9 block groups
    32768 blocks per group, 32768 fragments per group
    7312 inodes per group
    Superblock backups stored on blocks:
            32768, 98304, 163840, 229376

    Writing inode tables: done
    Creating journal (8192 blocks): done
    Writing superblocks and filesystem accounting information: done

    This filesystem will be automatically checked every 24 mounts or
    180 days, whichever comes first.  Use tune2fs -c or -i to override.


Device files for /dev/sdb1 and /dev/sdb2 have magically appeared somewhere in all the above steps:

    (SUPER-USER!) root@debian5vm: /root # ls -al /dev/sd*
    brw-rw---- 1 root disk 8,  0 2011-02-27 21:35 /dev/sda
    brw-rw---- 1 root disk 8,  1 2011-02-27 21:35 /dev/sda1
    brw-rw---- 1 root disk 8,  2 2011-02-27 21:35 /dev/sda2
    brw-rw---- 1 root disk 8,  5 2011-02-27 21:35 /dev/sda5
    brw-rw---- 1 root disk 8,  6 2011-02-27 21:36 /dev/sda6
    brw-rw---- 1 root disk 8, 16 2011-02-27 21:59 /dev/sdb
    brw-rw---- 1 root disk 8, 17 2011-02-27 21:59 /dev/sdb1 
    brw-rw---- 1 root disk 8, 18 2011-02-27 22:12 /dev/sdb2 


Create a mount-point directory /mnt/sdb2 :

    (SUPER-USER!) root@debian5vm: /root # cd /mnt

    (SUPER-USER!) root@debian5vm: /mnt # ls -al
    total 16
    drwxr-xr-x  4 root root 4096 2011-02-03 09:28 .
    drwxr-xr-x 21 root root 4096 2010-11-10 09:51 ..
    drwxr-xr-x  2 root root 4096 2011-02-03 09:14 cdrom
    drwxr-xr-x  2 root root 4096 2011-02-03 09:28 hgfs

    (SUPER-USER!) root@debian5vm: /mnt # mkdir sdb2

    (SUPER-USER!) root@debian5vm: /mnt # ls -al
    total 20
    drwxr-xr-x  5 root root 4096 2011-02-27 22:15 .
    drwxr-xr-x 21 root root 4096 2010-11-10 09:51 ..
    drwxr-xr-x  2 root root 4096 2011-02-03 09:14 cdrom
    drwxr-xr-x  2 root root 4096 2011-02-03 09:28 hgfs
    drwxr-xr-x  2 root root 4096 2011-02-27 22:15 sdb2

    (SUPER-USER!) root@debian5vm: /mnt # ls -al sdb2
    total 8
    drwxr-xr-x 2 root root 4096 2011-02-27 22:15 .
    drwxr-xr-x 5 root root 4096 2011-02-27 22:15 ..


Mount the new file system, and observe that there is already a directory (lost+found) there:

    (SUPER-USER!) root@debian5vm: /mnt # mount /dev/sdb2 /mnt/sdb2

    (SUPER-USER!) root@debian5vm: /mnt # cd sdb2

    (SUPER-USER!) root@debian5vm: /mnt/sdb2 # ls -al
    total 24
    drwxr-xr-x 3 root root  4096 2011-02-27 22:12 .
    drwxr-xr-x 5 root root  4096 2011-02-27 22:15 ..
    drwx------ 2 root root 16384 2011-02-27 22:12 lost+found


(SUPER-USER!) root@debian5vm: /mnt # cd /mnt (SUPER-USER!) root@debian5vm: /mnt # df Filesystem 1K-blocks Used Available Use% Mounted on /dev/sda1 2395540 1688880 584972 75% / tmpfs 258148 0 258148 0% /lib/init/rw udev 10240 696 9544 7% /dev tmpfs 258148 0 258148 0% /dev/shm /dev/sda6 5534416 143572 5109712 3% /home /dev/sdb2 1035692 34108 948972 4% /mnt/sdb2
(SUPER-USER!) root@debian5vm: /mnt # mount /dev/sda1 on / type ext3 (rw,errors=remount-ro) tmpfs on /lib/init/rw type tmpfs (rw,nosuid,mode=0755) proc on /proc type proc (rw,noexec,nosuid,nodev) sysfs on /sys type sysfs (rw,noexec,nosuid,nodev) procbususb on /proc/bus/usb type usbfs (rw) udev on /dev type tmpfs (rw,mode=0755) tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev) devpts on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=620) /dev/sda6 on /home type ext3 (rw) none on /proc/fs/vmblock/mountPoint type vmblock (rw) /dev/sdb2 on /mnt/sdb2 type ext3 (rw)

Edit /etc/fstab to add a line to define and auto-mount /dev/sdb2 when the system is booted:

    (SUPER-USER!) root@debian5vm: /mnt # vi /etc/fstab
    # /etc/fstab: static file system information.
    #
    # <file system> <mount point>   <type>  <options>       <dump>  <pass>
    proc            /proc           proc    defaults        0       0
    /dev/sda1       /               ext3    errors=remount-ro 0       1
    /dev/sda6       /home           ext3    defaults        0       2
    /dev/sda5       none            swap    sw              0       0
    /dev/sdb2       /mnt/sdb2       ext3    defaults        0       2
    /dev/hdc        /media/cdrom0   udf,iso9660 user,noauto     0       0
    /dev/fd0        /media/floppy0  auto    rw,user,noauto  0       0

Working with swap partitions and files: Save that for another day. Maybe tomorrow.
Ditto for those shell scripts to mount and unmount /dev/sdb2 and the swap partition.
Tomorrow. Or some day Real Soon Now.


Ready to re-boot now and see if it gets auto-mounted and if everything is still there!


Upon re-booting the system, observe that the new file system /dev/sdb2 is automatically mounted:

    jeremy@debian5vm: /home/jeremy $ df
    Filesystem           1K-blocks      Used Available Use% Mounted on
    /dev/sda1              2395540   1689092    584760  75% /
    tmpfs                   258148         0    258148   0% /lib/init/rw
    udev                     10240       696      9544   7% /dev
    tmpfs                   258148         0    258148   0% /dev/shm
    /dev/sda6              5534416    143572   5109712   3% /home
    /dev/sdb2              1035692     34108    948972   4% /mnt/sdb2 

    jeremy@debian5vm: /home/jeremy $ mount
    /dev/sda1 on / type ext3 (rw,errors=remount-ro)
    tmpfs on /lib/init/rw type tmpfs (rw,nosuid,mode=0755)
    proc on /proc type proc (rw,noexec,nosuid,nodev)
    sysfs on /sys type sysfs (rw,noexec,nosuid,nodev)
    procbususb on /proc/bus/usb type usbfs (rw)
    udev on /dev type tmpfs (rw,mode=0755)
    tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev)
    devpts on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=620)
    /dev/sda6 on /home type ext3 (rw)
    /dev/sdb2 on /mnt/sdb2 type ext3 (rw) 
    none on /proc/fs/vmblock/mountPoint type vmblock (rw)

    jeremy@debian5vm: /home/jeremy $ ls -al /mnt/sdb2
    total 24
    drwxr-xr-x 3 root root  4096 2011-02-27 22:24 .
    drwxr-xr-x 5 root root  4096 2011-02-27 22:15 ..
    drwx------ 2 root root 16384 2011-02-27 22:24 lost+found
    
    jeremy@debian5vm: /home/jeremy $     


End of transcript.        ◄ Home        ◄ Back to Mid-Term Debian log