Results 1 to 7 of 7

Thread: How to delete all files & directories from broken distro installation

  1. #1
    Join Date
    Jul 2014
    Beans
    53

    How to delete all files & directories from broken distro installation

    I have broken my Linux Lite and it has to be re-installed from scratch. As I'am using Grub4Dos to boot all my distros, I don't want to format the root and home partitions when reinstalling so that the device numbers of all partitions remain intact. After booting to Xubuntu, what would be the best commands to delete all files and directories in the broken OS before fresh re-install. Is this enough:

    Code:
    rm -rf /media/user_name/broken_os_folder/*
    rm -rf /media/user_name/broken_os_folder/
    or:
    Code:
    rm -rdf /media/user_name/broken_os_folder/*
    rm -rdf /media/user_name/broken_os_folder/
    In my case the broken OS is installed to:
    Code:
    /dev/sda21
    /dev/sda22
    I don't worry about Grub2, MBR and all that, because, as mentioned before, I'm using Grub4Dos to boot to all my distros, completely bypassing Grub2. In case someone is curious how to do it here is Menu.lst:

    Code:
    # Grub4Dos file Menu.lst
    title Xubuntu
    root (hd0,22)
    kernel /boot/vmlinuz-3.13.0-32-generic root=UUID=4ghka89-5586-3b77-8r6c-49f28g17d4n9 ro
    initrd /boot/initrd.img-3.13.0-32-generic
    Linux Lite 2.4, Xubuntu 14.04.2, Manjaro-Xfce, SolydX

  2. #2
    Join Date
    Nov 2011
    Location
    /dev/root
    Beans
    Hidden!

    Re: How to delete all files & directories from broken distro installation

    Before doing things like this you should backup everything valuable (personal files like photos, documents etc). You might make a mistake and remove data from the wrong partition.

    I think these are separate partitions that you want to wipe clean.

    I don't think it is necessary to wipe the partition to make it unreadable for security reasons. In this case you can

    - boot from another drive, for example a DVD/USB drive with an Ubuntu desktop install system

    - start gparted and simply format the two partitions

    Code:
    /dev/sda21
    /dev/sda22
    to the file systems you want. Then the files won't be there, and they are clean for a new installation. This is much more efficient than using the rm command. (But the content of some of the files can be recovered with a tool like PhotoRec.)

  3. #3
    Join Date
    Jun 2006
    Location
    UK
    Beans
    Hidden!
    Distro
    Ubuntu 20.04 Focal Fossa

    Re: How to delete all files & directories from broken distro installation

    Quote Originally Posted by Kirkx View Post
    I don't want to format the root and home partitions when reinstalling so that the device numbers of all partitions remain intact.
    If you simply reformat the partitions, their device numbers - I assume sda21 and sda22 - should remain the same. They are only likely to change if you actually delete the partitions with gparted and then re-create them. Their UUIDs will change if you reformat, but that doesn't appear to be a problem for you as you are using partition numbers for the root line in your grub4dos menu.lst rather than UUIDs.
    Ubuntu 18.04 Desktop Guide - Ubuntu 20.04 Desktop Guide - Forum Guide to BBCode - Using BBCode code tags - IRC #ubuntuforums

    Member: Not Canonical Team

    If you need help with your forum account, such as SSO login issues, username changes, etc, the correct place to contact an admin is here. Please do not PM me about these matters unless you have been asked to - unsolicited PMs concerning forum accounts will be ignored.

  4. #4
    Join Date
    Jul 2014
    Beans
    53

    Re: How to delete all files & directories from broken distro installation

    Coffeecat: If you simply reformat the partitions, their device numbers - I assume sda21 and sda22 - should remain the same. They are only likely to change if you actually delete the partitions with Gparted and then re-create them. Their UUIDs will change if you reformat,
    Thanks, that's correct, I have confused formatting with deleting/re-creating. I've just tested this using Gparted Live CD and it works as follows:

    a) formatting a partition - device number remains the same, UUID will change
    b) resizing a partition - both device number and UUID remain the same
    c) deleting and re-creating a partition in the same location on the hard disk - both device number and UUID will change

    There is one more scenario that I'm not sure about:

    d) restoring a partition from Clonezilla disk image - ?

    Their UUIDs will change if you reformat, but that doesn't appear to be a problem for you as you are using partition numbers for the root line in your grub4dos menu.lst rather than UUIDs
    With Grub4Dos you are actually using the device number in the root line and UUID in the kernel line, but under normal conditions this is not an issue because they never change. The only thing that must be occasionally manually edited is the kernel version (after each kernel update), but that's a small price to pay for freedom from Grub2 scripts.
    Last edited by Kirkx; July 31st, 2014 at 03:22 PM. Reason: correction
    Linux Lite 2.4, Xubuntu 14.04.2, Manjaro-Xfce, SolydX

  5. #5
    Join Date
    Jun 2006
    Location
    UK
    Beans
    Hidden!
    Distro
    Ubuntu 20.04 Focal Fossa

    Re: How to delete all files & directories from broken distro installation

    Quote Originally Posted by Kirkx View Post
    With Grub4Dos you are actually using the device number in the root line and UUID in the kernel line, but under normal conditions this is not an issue because they never change.
    My apologies - I hadn't noticed the UUID in the kernel line. Yes, you would need to edit this if you reformat your root partition.

    From what you have posted it looks as though grub4dos uses the old legacy grub syntax for its menu.lst. In which case, if my memory is correct, you could probably use /dev/sdXY in the kernel line and/or the UUID in the root line.

    I've never used clonezilla, so I can't help you with that.
    Ubuntu 18.04 Desktop Guide - Ubuntu 20.04 Desktop Guide - Forum Guide to BBCode - Using BBCode code tags - IRC #ubuntuforums

    Member: Not Canonical Team

    If you need help with your forum account, such as SSO login issues, username changes, etc, the correct place to contact an admin is here. Please do not PM me about these matters unless you have been asked to - unsolicited PMs concerning forum accounts will be ignored.

  6. #6
    Join Date
    Nov 2011
    Location
    /dev/root
    Beans
    Hidden!

    Re: How to delete all files & directories from broken distro installation

    Quote Originally Posted by Kirkx View Post
    Thanks, that's correct, I have confused formatting with deleting/re-creating. I've just tested this using Gparted Live CD and it works as follows:

    a) formatting a partition - device number remains the same, UUID will change
    Yes
    b) resizing a partition - device number remains the same, UUID will change
    UUID will also remain the same
    c) deleting and re-creating a partition in the same location on the hard disk - both device number and UUID will change
    Well, device number might be the same or change
    There is one more scenario that I'm not sure about:

    d) restoring a partition from Clonezilla disk image - ?
    Assuming there is already the old partition, that you rewrite to, the device number will remain. UUID is backed up, so it will remain the same.


    With Grub4Dos you are actually using the device number in the root line and UUID in the kernel line, but under normal conditions this is not an issue because they never change. The only thing that must be occasionally manually edited is the kernel version (after each kernel update), but that's a small price to pay for freedom from Grub2 scripts.
    For ext file systems you can identify the UUID in /boot/grub/grub.cfg and /etc/fstab and write that string into the partition with

    Code:
    tune2fs -U string /dev/sdxy
    where x is the drive name and y is the partition number, or do the change the other way around, enter the new UUID into /boot/grub/grub.cfg and /etc/fstab

  7. #7
    Join Date
    Jul 2014
    Beans
    53

    Re: How to delete all files & directories from broken distro installation

    Thanks for all your tips, Sudodus. I've meade an edit in p b) in my previous post, it was a misprint.
    coffeecat: From what you have posted it looks as though grub4dos uses the old legacy grub syntax for its menu.lst. In which case, if my memory is correct, you could probably use /dev/sdXY in the kernel line and/or the UUID in the root line.
    Yes, it's the legacy syntax, you can combine root and kernel lines. So instead of this code:
    Code:
    # Grub4Dos file Menu.lst
    title Xubuntu
    root (hd0,22)
    kernel /boot/vmlinuz-3.13.0-32-generic root=UUID=4ghka89-5586-3b77-8r6c-49f28g17d4n9 ro
    initrd /boot/initrd.img-3.13.0-32-generic
    you can use this one:
    Code:
    # Grub4Dos file Menu.lst
    title Xubuntu
    kernel (hd0,22)/boot/vmlinuz-3.13.0-32-generic root=UUID=4ghka89-5586-3b77-8r6c-49f28g17d4n9 ro
    initrd /boot/initrd.img-3.13.0-32-generic
    There are other ways to go about it, I haven't explored them all. The two versions shown above are fast and reliable.
    Linux Lite 2.4, Xubuntu 14.04.2, Manjaro-Xfce, SolydX

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
  •