Results 1 to 19 of 19

Thread: Swap partitions and redoing my disks1188 days old

  1. #1
    Registered User
    Join Date
    Oct 2005
    Location
    Nottingham MD
    Posts
    253
    Threads
    42
    Local Date
    06-19-2013
    Local Time
    03:12 PM

    Swap partitions and redoing my disks

    I currently have 2 320GB SATA hard disks in my Slackware 13/64 bit system and my second hard drive has a single partition mounted on /data which is backups of windows programs so when doing a re-install of windows we can get the programs locally, as well as user home directories (so /home is mapped to /data/home/username). The first hard drive has multiple partitions. The primary partitions are swap partitions (sda1 - sda3), sda4 is an extended partition sda5 is another swap partition and sda6 is the root file system /. In a few weeks I am planning on getting a 1TB or greater drive that will replace the sdb1 drive and it will be formatted and put in another system in the house after the data is moved. What I want to do is on sda delete partition sda1 - sda3 (which are swap partitions) and make it 1 swap, BUT I want to avoid re-doing the system if it can be done, so when creating the new partition I would start at position 1 and end where sda3 ends and then format it as swap. Will this work without having to re-do the system (will include fdisk, fstab and so on of sda below) and are there anything I should be careful of?
    Code:
    root@krazy:~# fdisk /dev/sda
    
    The number of cylinders for this disk is set to 38913.
    There is nothing wrong with that, but this is larger than 1024,
    and could in certain setups cause problems with:
    1) software that runs at boot time (e.g., old versions of LILO)
    2) booting and partitioning software from other OSs
       (e.g., DOS FDISK, OS/2 FDISK)
    
    Command (m for help): p
    
    Disk /dev/sda: 320.0 GB, 320072933376 bytes
    255 heads, 63 sectors/track, 38913 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes
    Disk identifier: 0xbb1a3e58
    
       Device Boot      Start         End      Blocks   Id  System
    /dev/sda1               1         654     5253223+  82  Linux swap
    /dev/sda2             655        1308     5253255   82  Linux swap
    /dev/sda3            1309        1962     5253255   82  Linux swap
    /dev/sda4            1963       38913   296808907+   5  Extended
    /dev/sda5            1963        2616     5253223+  82  Linux swap
    /dev/sda6            2617       38913   291555621   83  Linux
    
    Command (m for help):
    I know I stuck with sda5 being a swap unless I can find another use for a 5GB partitions and my numbering of the partitions will be off and will need to adjust fstab to mach changes. When done I would have sda1 that starts at 1 and ends at 1692 then sda4 - sda6 would remain unchanged.
    Code:
    root@krazy:~# cat /etc/fstab
    /dev/sda1        swap             swap        defaults         0   0
    /dev/sda2        swap             swap        defaults         0   0
    /dev/sda3        swap             swap        defaults         0   0
    /dev/sda5        swap             swap        defaults         0   0
    /dev/sda6        /                ext4        defaults         1   1
    /dev/sdb1        /data            ext4        defaults         1   2
    #/dev/cdrom      /mnt/cdrom       auto        noauto,owner,ro  0   0
    /dev/fd0         /mnt/floppy      auto        noauto,owner     0   0
    devpts           /dev/pts         devpts      gid=5,mode=620   0   0
    proc             /proc            proc        defaults         0   0
    tmpfs            /dev/shm         tmpfs       defaults         0   0
    root@krazy:~#
    
    root@krazy:~# df -hT
    Filesystem    Type    Size  Used Avail Use% Mounted on
    /dev/root     ext4    274G  8.7G  252G   4% /
    /dev/sdb1     ext4    294G  116G  164G  42% /data
    tmpfs        tmpfs    2.0G     0  2.0G   0% /dev/shm

  2. #2
    Slightly unbalanced Dark Angel's Avatar
    Join Date
    Jun 2005
    Location
    Oztrayleeah
    Posts
    15,192
    Threads
    1864

    Awards Showcase

    Real Name
    Mick
    Local Date
    06-20-2013
    Local Time
    05:12 AM
    I don't understand why you have so many swap partitions. A single 5gig swap should be plenty and even if you're handling MASSIVE files a 10gig swap would cover pretty much anything.
    Having 5 swap partitions is just wasting drive space and creating unnecessary system overhead.
    About the only trick that I've ever been able to justify with swap is to have it as the first partition on a drive on a different channel to the one with the OS and applications so they both be accessed at the same time. (ie both on the same IDE cable doesn't help.)
    Power is something that should be given to those who need it to serve and withheld from those who seek it to rule.

  3. #3
    Registered User
    Join Date
    Oct 2005
    Location
    Nottingham MD
    Posts
    253
    Threads
    42
    Local Date
    06-19-2013
    Local Time
    03:12 PM

    Quote Originally Posted by Dark Angel View Post
    I don't understand why you have so many swap partitions. A single 5gig swap should be plenty and even if you're handling MASSIVE files a 10gig swap would cover pretty much anything.
    When I first got into Linux I was told by someone I was better to have multiple swap disks then 1. I had them too small as pointed out on another post here (I think it was the post with what happened when I tried to get Ubuntu installed on here). So I re-did the system with 4 swap partitions and made them 5GB each. I can re-do the system when I get the other hard drive, it not a big deal to back up everything to sdb1 re-do the operating system without formatting sdb1 then when done installing copy all the stuff back. Think I hold back doing it until I actually get the other drive though so I can do it all at once because it will take a long time to do with checking a 1 - 1.5TB even with partitioning it in 300GB chunks you will be looking at like 1hr per 300GB chunk.

  4. #4
    Hell's Very Own Grogan's Avatar
    Join Date
    Sep 2002
    Location
    Ontario, Canada
    Posts
    23,198
    Threads
    2415

    Awards Showcase

    Real Name
    Hugh Jorgen
    Local Date
    06-19-2013
    Local Time
    03:12 PM
    The first three (sda1, sda2 and sda3) are primary partitions and are safe to delete (and recreate new primary partitions on that space without destroying any that follow, provided you don't do something stupid like overlap boundaries)

    You would not want to delete sda5, for it's a logical drive on the extended. The only time it's safe to delete one logical drive is when it's the last one. Logical drives are "daisy chained" with each containing information in its first sector about the next one. So if you delete sda5, you lose the rest of the logical drives... in this case, sda6 which is your root partition.

    This applies to both Windows and Linux using "pcbios" partition tables. You can only safely delete logical drives starting with the last one.

  5. #5
    Slightly unbalanced Dark Angel's Avatar
    Join Date
    Jun 2005
    Location
    Oztrayleeah
    Posts
    15,192
    Threads
    1864

    Awards Showcase

    Real Name
    Mick
    Local Date
    06-20-2013
    Local Time
    05:12 AM
    Quote Originally Posted by krazykanuk36 View Post
    When I first got into Linux I was told by someone I was better to have multiple swap disks then 1.
    I remember you saying that before, but I've never heard anyone speak of or do it that way before or since. Certainly not for a PC. Perhaps in a heavily virtualized server environment there might be a reason to do that, to stop different VMs from over-writing each others swap data, but I would have thought the various environment managers (vbox, VMware etc) would handle that anyway.

  6. #6
    Registered User
    Join Date
    Oct 2005
    Location
    Nottingham MD
    Posts
    253
    Threads
    42
    Local Date
    06-19-2013
    Local Time
    03:12 PM

    Quote Originally Posted by Grogan View Post
    The first three (sda1, sda2 and sda3) are primary partitions and are safe to delete (and recreate new primary partitions on that space without destroying any that follow, provided you don't do something stupid like overlap boundaries)
    OK my assumptions here were right I was going to delete the swaps on 1,2,and 3 and make 1 in that space and format accordingly.

    Quote Originally Posted by Grogan View Post
    You would not want to delete sda5, for it's a logical drive on the extended. The only time it's safe to delete one logical drive is when it's the last one. Logical drives are "daisy chained" with each containing information in its first sector about the next one. So if you delete sda5, you lose the rest of the logical drives... in this case, sda6 which is your root partition.

    This applies to both Windows and Linux using "pcbios" partition tables. You can only safely delete logical drives starting with the last one.
    sda4, sda5, sda6 I was leaving untouched. The only way I could get rid of sda5 (which you confirmed) would be to re-do the system or if it was the last partition which it is not.

  7. #7
    Arch Ninja sagecss's Avatar
    Join Date
    Jan 2006
    Posts
    466
    Threads
    46
    Local Date
    06-20-2013
    Local Time
    05:12 AM
    As DA mentioned, combining all the primary partitions should be plenty for a swap partition, and that is what you are planning on doing anyway to tidy things up a little.

    Quote Originally Posted by krazykanuk36 View Post
    ...The only way I could get rid of sda5 (which you confirmed) would be to re-do the system or if it was the last partition which it is not.
    I like to have my partitions the way I want them, else it gnaws at me from deep down in my subconscious somewhere I know, but that's how it is

    You can have that drive in your own prestine configuration in very little time without having to redo the OS, by using the dd or cp command. That is what I would do, you are going through the trouble anyway. Make sure that the partition to be backed up i.e. sda6 is not mounted if you are going to do this.

    You probably have LILO / GRUB installed to the MBR on sda? so there should be no problem.
    Last edited by sagecss; 03-19-2010 at 04:08 PM.

  8. #8
    Registered User
    Join Date
    Oct 2005
    Location
    Nottingham MD
    Posts
    253
    Threads
    42
    Local Date
    06-19-2013
    Local Time
    03:12 PM

    Unless I am missing something here (which is totally possible) I HAVE to mount sda6 it contains the OS. I have the room to copy it to sdb1. What you said has got the wheels turning though, I am going to look to see what LIVE-CD's I have and make sure it supports SATA and if it does I can copy sda6 over to sdb1 run fdisk on sda fix to my liking and then copy everything back to sdaX

  9. #9
    Hell's Very Own Grogan's Avatar
    Join Date
    Sep 2002
    Location
    Ontario, Canada
    Posts
    23,198
    Threads
    2415

    Awards Showcase

    Real Name
    Hugh Jorgen
    Local Date
    06-19-2013
    Local Time
    03:12 PM
    That's what I would do also, only it's not "dd" you want to use for this. (You want to copy and restore data to different partitions, not a low level copy of disk sectors)

    I personally use "tar czfp" for those kinds of operations (and then write through a mount point when extracting the archive with "tar xzfp"), but you could also use "cp -a" which (like tar) copies all permissions and timestamps and stuff if done as root. Also very important, it preserves symbolic links as they are.

    Then you fix up fstab, your boot loader config and then boot with other media to jump start your system. (use its kernel and boot loader but specify your root filesystem)

    Since this is slackware, look no further than your slackware installation CD/DVD both for the copy operation and for jumpstarting the system afterwards (It's perfect for that, with the fat assed kernel image that supports everyfuckingthing(tm)). He even displays the instructions for you on the initial boot screen.

    You can use fdisk, mke2fs, cp -a, vi, mount, etc.

  10. #10
    Arch Ninja sagecss's Avatar
    Join Date
    Jan 2006
    Posts
    466
    Threads
    46
    Local Date
    06-20-2013
    Local Time
    05:12 AM
    Quote Originally Posted by krazykanuk36 View Post
    Unless I am missing something here (which is totally possible) I HAVE to mount sda6 it contains the OS. I have the room to copy it to sdb1. What you said has got the wheels turning though, I am going to look to see what LIVE-CD's I have and make sure it supports SATA and if it does I can copy sda6 over to sdb1 run fdisk on sda fix to my liking and then copy everything back to sdaX
    Sorry, I can see the confusion in what I said...what I mean in short is don't try to cp or tar from your standard booted system, use the slackware install CD, as Grogan stated.

  11. #11
    Registered User
    Join Date
    Oct 2005
    Location
    Nottingham MD
    Posts
    253
    Threads
    42
    Local Date
    06-19-2013
    Local Time
    03:12 PM

    Quote Originally Posted by Grogan View Post
    I personally use "tar czfp" for those kinds of operations (and then write through a mount point when extracting the archive with "tar xzfp"), but you could also use a "cp -a" which copies all permissions and timestamps and stuff if done as root.
    OK I acm doing something wrong or something. I booted with the slackware DVD and when I got a prompt entered huge.s root=/dev/sda6 ro rdinit=ro and booted fine, switched to the / directory start to copy with cp -a foldername /data/sys-backup all goes well until the sys and proc folders. I get a whole string of errors like permission denied and illeagal operations, on the proc folder I get a input output error on sysreq-something as soon as I press enter and I let it copy proc for 4 and a half hours and it didn't finish. I shut it down for now, will try again in the morning without booting from slackware DVD. when I used tar czfp directory filename.tar.gz I got similar results will do it again in morning when I have more time and not being bitched at over linux being down.

  12. #12
    Hell's Very Own Grogan's Avatar
    Join Date
    Sep 2002
    Location
    Ontario, Canada
    Posts
    23,198
    Threads
    2415

    Awards Showcase

    Real Name
    Hugh Jorgen
    Local Date
    06-19-2013
    Local Time
    03:12 PM
    No, as sagecss said, you can't do it on a live system. That's just the same as booting from your hard drive and trying to copy. You jumpstart like that only to get in and reinstall the boot loader after moving your Linux installation and fixing up your configs.

    Just boot with the slackware dvd and hit enter to boot huge.s (or type huge.s and hit enter). Log in as root (there's no password) and then mount your filesystem.

    Here's how I'd do it. The mount points are arbitrary, call them what you want. Note that this assumes you're not going to make any mistakes. If you do, you will cry.

    Code:
    mkdir /mnt/myslack
    mkdir /mnt/data
    mount -t ext4 /dev/sda6 /mnt/myslack
    mount -t ext4 /dev/sdb1 /mnt/data
    cd /mnt
    tar czfp /mnt/data/slackware.tar.gz myslack
    This will tar up myslack and EVERYTHING under it, which just happens to be the mount point of your root filesystem. So you'll have a perfect archive of your root fs with the top level directory in the archive "myslack". As long as we write it through the mount point of the same name that will be cool.

    Now, unmount your slack filesystem:

    Code:
    umount /mnt/myslack
    Do your dirty work with fdisk... delete the partitions you don't want and make yourself a nice fat /dev/sda1 and a swap partition.

    Format your filesystems:

    Code:
    mke2fs -t ext4 /dev/sda1
    (you can also use mkfs.ext4 if present in the slackware install environment... "mkfs.ext4 /dev/sda1" but the above command will for sure work with a version of mke2fs that supports ext4)

    Code:
    mkswap /dev/sda2
    (or whatever your swap partition ends up being... sda5 if logical)

    Note that if you mess with logical drives, you may need to reboot before formatting to get the kernel to use the new partition tables correctly. You will then have to create your mount points again (e.g. mkdir /mnt/myslack etc. and mount /mnt/data where your archive is)

    Now, to untar your system over again...

    Mount your new filesystem:

    Code:
    mount -t ext4 /dev/sda1 /mnt/myslack
    untar your archive:

    Code:
    cd /mnt/data
    tar xzfp slackware.tar.gz -C /mnt
    You may think that is strange, but since the directory in the archive is "myslack" which is the same name as our mount point /mnt/myslack, it will write through that mount point and everything will be in its correct place on that filesystem.

    Alright... now go fix up fstab on /mnt/myslack and your boot loader config (lilo.conf or grub's menu.lst) to reflect the change in partitions.

    NOW is the time you will want to reboot with the slackware DVD and do the:

    Code:
    huge.s root=/dev/sda1 ro rdinit=ro
    To jump start your system. If your fstab is correct you'll be booted from your system on /dev/sda1. Now, if your boot loader config is correct you can run "lilo" or "grub-install /dev/sda" to reinstate it in the MBR

  13. #13
    Hell's Very Own Grogan's Avatar
    Join Date
    Sep 2002
    Location
    Ontario, Canada
    Posts
    23,198
    Threads
    2415

    Awards Showcase

    Real Name
    Hugh Jorgen
    Local Date
    06-19-2013
    Local Time
    03:12 PM
    Hey, before you do that, check the switches of tar while booted with the slackware DVD. I remember once with a certain version the syslinux environment used a tar with different syntax... the "p" switch was unnecessary or something like that.

    You can also change that procedure to use "cp -a" instead of tar. You should still be able to copy through the mount point. Let's say you copied /mnt/myslack to /mnt/data

    /dev/sda1 is mounted at /mnt/myslack

    Code:
    cd /mnt/data
    cp -a myslack /mnt

  14. #14
    Registered User
    Join Date
    Oct 2005
    Location
    Nottingham MD
    Posts
    253
    Threads
    42
    Local Date
    06-19-2013
    Local Time
    03:12 PM

    Quote Originally Posted by Grogan View Post
    Hey, before you do that, check the switches of tar while booted with the slackware DVD. I remember once with a certain version the syslinux environment used a tar with different syntax... the "p" switch was unnecessary or something like that.
    I had started it before I saw this, for the most part it went OK. I had saw your last post before I went to bed so I started it up til the tar (so I could let tar run while I slept). I woke and it was done. I followed you instructions to a "T" with the exception I put my swap on /dev/sda1 and the root filesystem on /dev/sda2. I finished and have errors when I reboot (nothing to call home and cry on mommy's shoulder over). I get a GRUB RESCUE> prompt, so I assume it is finding the partition correctly and when I edited /boot/grub/grub.cfg (it grub.cfg and not menu.lst because it is grub2), BUT I think I know what I did wrong. What I did was I edited /boot/grub/grub.cfg even though at the very top of the file it says not to. What I SHOULD have done was run
    Code:
    grub /dev/sda2
    grub-install /dev/sda2
    off top of my head I not sure which it is but it one of them. It is weird though because when I ran grub-mkconfig -o /boot/grub/grub.cfg it found all the proper kernels.

  15. #15
    Registered User
    Join Date
    Oct 2005
    Location
    Nottingham MD
    Posts
    253
    Threads
    42
    Local Date
    06-19-2013
    Local Time
    03:12 PM

    That was EXACTLY the problem ran
    Code:
    grub-install /dev/sda
    grub-mkconfig -o /boot/grub/grub.cfg
    and it is back up without the slackware DVD and smiling at me waiting for username/password.

  16. #16
    Arch Ninja sagecss's Avatar
    Join Date
    Jan 2006
    Posts
    466
    Threads
    46
    Local Date
    06-20-2013
    Local Time
    05:12 AM
    Glad you got it sorted

  17. #17
    Registered User
    Join Date
    Oct 2005
    Location
    Nottingham MD
    Posts
    253
    Threads
    42
    Local Date
    06-19-2013
    Local Time
    03:12 PM

    The only other thing that I had to do was I had the grub configuration file loaded (/boot/grub/grub.cfg) in vi scratching my head to remember the commands in vi, finally remembered and couldn't save because the filesystem was loaded read only
    Code:
    chmod 755 grub.cfg
    made changes and then set back to
    Code:
    chmod 400 grub.cfg
    This is the part where I should have ran
    Code:
    grub-install /dev/sda 
    grub-mkconfig -o /boot/grub/grub.cfg

  18. #18
    Hell's Very Own Grogan's Avatar
    Join Date
    Sep 2002
    Location
    Ontario, Canada
    Posts
    23,198
    Threads
    2415

    Awards Showcase

    Real Name
    Hugh Jorgen
    Local Date
    06-19-2013
    Local Time
    03:12 PM
    Sorry, I didn't realize that slack used grub2 (I still use lilo when I do a test install of slack)

  19. #19
    Registered User
    Join Date
    Oct 2005
    Location
    Nottingham MD
    Posts
    253
    Threads
    42
    Local Date
    06-19-2013
    Local Time
    03:12 PM

    Quote Originally Posted by Grogan View Post
    Sorry, I didn't realize that slack used grub2 (I still use lilo when I do a test install of slack)
    Not your fault was mine. Slackware doesn't use grub2 I installed it after the system was up and working but before I did the kernel. I should have known better and read the BIG BOLD print in grub.cfg that said DO NOT EDIT. But I have before and what I did worked (just dropped the timeout down to 3 seconds) so I figured changing /dev/sda6 to /dev/sda2 and (hd0,6) to (hd0,2) should have worked. What I failed to realize is that when I deleted all partitions on /dev/sda and formatted be it a swap or root partition I also deleted the bootloader that was installed to the MBR. If I would have slowed down a little I would have thought it out more and realized and would have done this before I rebooted and got the grub rescue prompt. I even missed your post this morning about the p option in tar because I saw the other one and started everything and went to bed, and those posts were only 2 minutes apart.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •