• Taking Disk Cylinders From Swap on Solaris 8

    Kids… DO NOT TRY THIS AT HOME! If this is not done exactly right, you will render your system unbootable and corrupt your data. That being said, under some circumstances you can take some space from your swap partition and add it to an unused one without initializing your entire disk. This is particularly useful if you decide you want to use DiskSuite to mirror your system disk, but have not allocated the 100MB partition that is needed to hold the state databases. As always, BACK EVERYTHING UP FIRST. Better yet, make two backups and store them on two different systems. This is a risky procedure, and you don’t want to lose any data!

    You can also use my instructions for copying a Solaris boot drive to a disk with a different partition layout as a safer alternative.

    The first thing you need to do is figure out if your disk layout will allow for this procedure. Usually the swap partition is the second one on the disk, making it partition number 1 (Partition number 0 is root). If partition number 1 is swap on your system, and partition number 3 or 4 are unused, you are in good shape, and this should work. To figure this out, you should do something like this:

    # format
    Select the boot disk - usually disk 0
    Specify disk (enter its number): 0
    format> partition
    format> print

    This will show you the current disk layout.

    
    Current partition table (original):
    Total disk cylinders available: 24620 + 2 (reserved cylinders)
    
    Part      Tag    Flag     Cylinders         Size            Blocks
      0       root    wm       0 -   725        1.00GB    (726/0/0)    2097414
      1       swap    wu     726 -  9436       11.90GB    (8635/0/0)  24946515
      2     backup    wm       0 - 24619       33.92GB    (24620/0/0) 71127180
      3 unassigned    wm       0                0         (0/0/0)            0
      4 unassigned    wm       0                0         (0/0/0)            0
      5        usr    wm    9437 - 10888        2.00GB    (1452/0/0)   4194828
      6        var    wm   10889 - 18148       10.00GB    (7260/0/0)  20974140
      7 unassigned    wm   18149 - 24619        8.91GB    (6471/0/0)  18694719
    

    Here we see that partitions 3 and 4 are unused and directly after partition 1, so we can take some space from swap and assign it to one of these. Partition 2 is, of course the entire disk. I have not tried it, so I don’t know if you could assign non-sequential cylinders to a partition that is not directly after swap.

    So to take some space from partition 1 and add it to partition 3, the first thing we have to do is disable swap, so the format utility will let us change it.

    Comment out the following lines in your /etc/vfstab file and reboot the system.

    
    #/dev/dsk/c1t0d0s1         -       -               swap    -       no      -
    #swap    -       /tmp    tmpfs   -       yes     -
    

    This will bring the system up without swap enabled. You can now edit the disk label. Remember that our cylinders need to be sequential, so always work in cylinders when using the format utility.

    Re-enter the format utility, select your system disk and view the partition table:

    # format
    Select the boot disk - usually disk 0
    Specify disk (enter its number): 0
    format> partition
    format> print

    Again we wee that partitions 3 and 4 are unused.

    
    Current partition table (original):
    Total disk cylinders available: 24620 + 2 (reserved cylinders)
    
    Part      Tag    Flag     Cylinders         Size            Blocks
      0       root    wm       0 -   725        1.00GB    (726/0/0)    2097414
      1       swap    wu     726 -  9436       11.90GB    (8635/0/0)  24946515
      2     backup    wm       0 - 24619       33.92GB    (24620/0/0) 71127180
      3 unassigned    wm       0                0         (0/0/0)            0
      4 unassigned    wm       0                0         (0/0/0)            0
      5        usr    wm    9437 - 10888        2.00GB    (1452/0/0)   4194828
      6        var    wm   10889 - 18148       10.00GB    (7260/0/0)  20974140
      7 unassigned    wm   18149 - 24619        8.91GB    (6471/0/0)  18694719
    

    The first thing we need to do is take some cylinders away from partition 1. In this example, we are looking to make partition 3 roughly 100MB, so we need to take about 75 cylinders from partition 1 so that we can add it to partition 3. Parititon 1 ends at cylinder 9436, so we need to subtract 75 from that number. 9436 - 75 = 9361, so that is the new ending cylinder for partition 1. We then subtract the beginning cylinder (726) from that number to give us the new total number of cylinders for partition 1. 9361 - 726 = 8635, so this is the number we enter when format asks for the size of the partition. Like so:

    
    partition> 1
    Part      Tag    Flag     Cylinders         Size            Blocks
      1       swap    wu     726 -  9360       11.90GB    (8635/0/0)  24946515
    
    Enter partition id tag[swap]:
    Enter partition permission flags[wu]:
    Enter new starting cyl[726]:
    Enter partition size[24946615b, 9436c, 12880.92mb, 12.00gb]: 8635c
    partition>
    

    Now we have to add these 75 cylinders to partition 3.

    
    partition> 3
    Part      Tag    Flag     Cylinders         Size            Blocks
      3 unassigned    wm       0                0          (0/0/0)            0
    
    Enter partition id tag[unassigned]:
    Enter partition permission flags[wm]:
    Enter new starting cyl[0]:9361
    Enter partition size[0b, 0c, 0.00mb, 0.00gb]:75c
    partition>
    

    Print out the new partition table to make sure everything lines up correctly:

    
    partition> print
    Current partition table (original):
    Total disk cylinders available: 24620 + 2 (reserved cylinders)
    
    Part      Tag    Flag     Cylinders         Size            Blocks
      0       root    wm       0 -   725        1.00GB    (726/0/0)    2097414
      1       swap    wu     726 -  9360       11.90GB    (8635/0/0)  24946515
      2     backup    wm       0 - 24619       33.92GB    (24620/0/0) 71127180
      3 unassigned    wm    9361 -  9436      107.21MB    (76/0/0)      219564
      4 unassigned    wm       0                0         (0/0/0)            0
      5        usr    wm    9437 - 10888        2.00GB    (1452/0/0)   4194828
      6        var    wm   10889 - 18148       10.00GB    (7260/0/0)  20974140
      7 unassigned    wm   18149 - 24619        8.91GB    (6471/0/0)  18694719
    

    Partition 1 ends at cylinder 9360, and partition 3 picks right up at cylinder 9361. Partition 3 ends at cylinder 9436, and partition 5 begins at cylinder 9437. Partition 4, of course, remains unused. Since none of the cylinders overlap, we can go ahead and write the disk label out. DO NOT DO THIS if you have any doubt at all about what you have just done. By writing out the disk label, you could corrupt the data on your formated filesystems if any cylinders overlap into them. The format utility is usually pretty smart about keeping you from making mistakes, but be very careful anyway! You don’t want to end up with scrambled eggs on a disk that has valuable data on it.

    partition> label
    This writes out the disk label, so you can now exit the format utility and re-enable swap in your /etc/vfstab file. Simply uncomment out the following two lines and reboot the system.

    
    /dev/dsk/c1t0d0s1         -       -               swap    -       no      -
    swap    -       /tmp    tmpfs   -       yes     -
    

    Reboot your system, and if all goes well, it will come up, and you will see that partition 3 will have a little over 100MB on it. Usually people want to do this so they can store the DiskSuite meta database on the newly created partition. If this is the case for you, you can now move on to mirroring the system disk.

    This entry was posted on Tuesday, November 21st, 2006 at 5:22 pm and is filed under Data and Technology. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.
  • 3 Comments

    Take a look at some of the responses we've had to this article.

    1. [...] Link:http://spiralbound.net/2006/11/21/taking-disk-cylinders-from-swap-on-solaris-8 BookmarkBookmark and Share This Page | « CloseSave to Browser FavoritesAskbackflipblinklistBloglinesBlogMarksBlogsvineBUMPzee!CiteULikeco.mmentsConnoteadel.icio.usDotNetKicksDiggdiigodropjack.comdzoneFacebookFarkFavesFeed Me LinksFriendsitefolkd.comFurlGoogleHuggJeqqKaboodlelinkaGoGoLinksMarkerMa.gnoliaMister WongMixxMySpaceMyWebNetvouzNewsvinePlugIMpopcurrentPropellerRedditRojoSegnaloShoutwireSimpysk*rtSlashdotSphereSphinnSpurl.netSquidooStumbleUponTailrankTechnoratiThisNextWebrideWindows LiveYahoo!Email This to a FriendHTML: If you like this then please subscribe to the RSS feed or Email feed.Powered by Bookmarkify™ More » Tags: computing, disksuite, Linux, Solaris, Solaris, solstice, Storage, technology [...]

    2. Hey,

      Its looks like pretty good. I want to publish your contents in my blog. Hope you will not get feel bad if I publish. Anyway I am going to put like of real content.

      Thanks,
      Kishore Thakur.

    3. Dan Bell
      Aug 27th
      Reply

      What’s with all the rebooting? This ain’t windows ;)

      Rather then editing your vfstab to comment out swap and then rebooting, you should just run:
      swap -d
      This will disable swap and allow you to modify it’s slice size.
      Then you can run format and re-partition your disk.
      After you’re done editing swap’s slice size, run:
      swap -a
      This will re-enable swap on your newly resized swap slice.
      Substituting in these steps will allow you to perform your operation without the two reboots.

  • Leave a Reply

    Let us know what you thought.

  • Name (required):

    Email (required):

    Website:

    Message:

Visitors have tagged this post: t (169) - solaris show partitions (50) - solaris view partitions (31) - partition (24) - solaris 8 format (23) - overlaps with c1t0d0s1 which is a swap device (22) - solaris swap (21) - solaris swap off (21) - solaris show partition table (20) - solaris swap partition (18) - solaris create "swap partition" (17) - solaris format wu (17) - solaris turn off swap (17) - solaris format script (16) - solaris format tag (16) - solaris format partition (15) - solaris show partition (15) - solaris view partition (15) - solaris slice 2 (15) - solaris show disk layout (14) - solaris format swap partition (14) - show partitions Solaris (14) - solaris swapoff (14) - solaris disk layout (12) - create swap partition + solaris (12) - Solaris 8 swap (12) - solaris format swap (12) - f (12) - solaris show slices (11) - all (10) - solaris show disks (10) - show partition solaris (10) - view solaris partitions (10) - solaris partition flags (9) - solaris reserved partition (9) - solaris format wu wm (9) - solaris format flag wu (9) - metadb overlaps with which is a swap device (9) - view partitions solaris (9) - Solaris "disable swap " (8) - metadb swap (8) - format wu wm (8) - solaris reserved cylinders (8) - swap solaris (8) - format soLARIS 8 (8) - solaris format disk (8) - show disks solaris (8) - solaris format reserved (8) - solaris show disk partition (8) - "format solaris" (8) - reserved partition Solaris (8) - overlaps with which is a swap device (8) - taking disk (8) - swapoff solaris (8) - +solaris +slice (7) - solaris swap format (7) - solaris disk label (7) - format swap solaris (7) - solaris show disk partitions (7) - solaris format (7) - solaris swap /tmp (7) - solaris format wm wu (7) - Solaris slices (7) - solaris slice 8 (7) - view partitions in solaris (7) - format partition solaris (7) - turn off swap solaris (7) - solaris make swap partition (6) - +"solaris 8" +format +disk (6) - solaris format partition tag (6) - solaris swap cylinder 0 (6) - solaris format slice 8 (6) - format solaris wu (6) - solaris format backup (6) - swap off solaris (6) - format wm wu (6) - solaris format tags (6) - solaris slice 8 reserved (6) - solaris partition table (6) - solaris creating swap partition (5) - create swap solaris (5) - solaris metadb swap (5) - format solaris disk (5) - how to create swap partition in solaris (5) - solaris swap -d (5) - flag wm wu (5) - Solaris swap partition create (5) - solaris partition label (5) - solaris 8 tmpfs (5) - format swap (5) - solaris format create partition (5) - solaris 8 partition (5) - solaris show disk (5) - create swap partition in Solaris (5) - solaris format "wu flag" (5) - show disk solaris (5) - Solaris format partition 8 reserved (5) - format disk solaris 8 (5) - print partition table solaris (5) - solaris format partition 8 (5) - "solaris partition flag " (5) - show partition table solaris (5) - metadb overlaps with which is a swap device (5) - solaris (4) - disk cylinder (4) - solaris copy partition table (4) - solaris format utility (4) - Total disk cylinders available (4) - solaris swap flag (4) - make swap Solaris (4) - solaris format wm (4) - solaris partition tag (4) - solaris view partition table (4) - swap solaris 8 (4) - disable swap solaris (4) - show solaris partition (4) - solaris disk cylinder (4) - solaris "add swap" partition (4) - Solaris partition id tag (4) - solaris 8 disk partitions (4) - solaris 8 disk label (4) - solaris partition flag wu (4) - solaris view disk partitions (4) - solaris format root disk (4) - Disk cylinders (4) - view partition in solaris (4) - solaris add disk (4) - solaris print partition table (4) - solaris 8 print partition table (4) - solaris 8 cylinders (4) - solaris format reserved partition (4) - show partitions on solaris (4) - format solaris partition (4) - show solaris partitions (4) - solaris format print (4) - solaris partition format (4) - solaris format partition print (4) - rebuilding solaris partition (4) - t2000 format for solaris disk (4) - create partition table solaris (4) - solaris disable swap (4) - format solaris (4) - disk slice solaris overlap (4) - naked (3) - solaris disk partitioning (3) - solaris disk partition (3) - solaris partition layout (3) - copy partition table solaris (3) - solaris create partition (3) - Solaris disk tag (3) -