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

Mid-Term: Transcript showing preparation and use
of swap area on second virtual disk partition /dev/sdb1

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.


This procedure is done entirely as super-user (except for the /sbin/swapon -s at the end).

We begin by checking the current state of the system for any evidence that /dev/sdb1 is already in use. We find, as expected, that fdisk reports that the system knows about this partition, but it is not otherwise in use:

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

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

     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


(SUPER-USER!) root@debian5vm: /root # df Filesystem 1K-blocks Used Available Use% Mounted on /dev/sda1 2395540 1962376 311476 87% / tmpfs 258148 0 258148 0% /lib/init/rw udev 10240 696 9544 7% /dev tmpfs 258148 0 258148 0% /dev/shm /dev/sda6 5534416 216568 5036716 5% /home /dev/sdb2 1035692 34108 948972 4% /mnt/sdb2
(SUPER-USER!) root@debian5vm: /root # swapon -s Filename Type Size Used Priority /dev/sda5 partition 329292 0 -1

Before we can use the swap partition, we must run this, once only, to prepare the partition as a swap area:

     (SUPER-USER!) root@debian5vm: /root # mkswap /dev/sdb1 
     Setting up swapspace version 1, size = 1069248 kB      
     no label, UUID=a0c3eb60-02fa-4369-91a7-83279e7d01cb    


Then, manually run swapon as shown here to test that it works.

More typically, we will add a line to /etc/fstab to auto-enable this swap partition when the system is booted, and never need to do this "by hand" again:

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

Verify that /dev/sdb1 swapping is now enabled:

     (SUPER-USER!) root@debian5vm: /root # swapon -s
     Filename                                Type            Size    Used    Priority
     /dev/sda5                               partition       329292  0       -1
     /dev/sdb1                               partition       1044184 0       -2 


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

(Here, add a line to /etc/fstab to enable swapping automatically at boot on /dev/sdb1)


     (SUPER-USER!) root@debian5vm: /root # 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/sdb1       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


Now, re-boot the machine to verify that the /dev/sdb1 swap area
will be enabled automatically when the system boots:

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




After re-booting, we see that the new swap area is still (or again) active:

     jeremy@debian5vm: /home/jeremy $ /sbin/swapon -s
     Filename                                Type            Size    Used    Priority
     /dev/sda5                               partition       329292  0       -1
     /dev/sdb1                               partition       1044184 0       -2 

     jeremy@debian5vm: /home/jeremy $    


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