[SOLVED] How to remove properly a FS (Directory)

ElectricEel

New Member
Mar 2, 2023
2
0
1
Hello,

I am digging up a old subject : Deleting properly a FileSystem.
I know that there is a very similar subjet here but the solution is for a Datastore not for a FS.

I am unable to recreate a FS with the same name of a FS that I have previously deleted.

Here is the full procedure :
Bash:
# List available disk
$ sudo proxmox-backup-manager disk list
┌──────┬─────────┬─────┬───────────┬─────────────┬───────────────┬─────────┬────────┐
│ name │ used    │ gpt │ disk-type │        size │ model         │ wearout │ status │
╞══════╪═════════╪═════╪═══════════╪═════════════╪═══════════════╪═════════╪════════╡
│ sda  │ mounted │   0 │ hdd       │ 21474836480 │ QEMU_HARDDISK │       - │ passed │
├──────┼─────────┼─────┼───────────┼─────────────┼───────────────┼─────────┼────────┤
│ sdb  │ unused  │   0 │ hdd       │ 34359738368 │ QEMU_HARDDISK │       - │ passed │
└──────┴─────────┴─────┴───────────┴─────────────┴───────────────┴─────────┴────────┘

# Initialize the desired disk
$ sudo proxmox-backup-manager disk initialize sdb
initialize disk sdb
TASK OK

# Create a FS on the disk
$ sudo proxmox-backup-manager disk fs create fs_critical_backup --disk sdb --filesystem ext4
Chunkstore create: 1%
Chunkstore create: 2%
...
Chunkstore create: 98%
Chunkstore create: 99%
TASK OK

# Check that the FS is correctly created
$ sudo proxmox-backup-manager disk fs list
┌──────────────────────────────────────┬────────────────────────────────────────────────────────┬────────────┬──────────┐
│ path                                 │ device                                                 │ filesystem │ options  │
╞══════════════════════════════════════╪════════════════════════════════════════════════════════╪════════════╪══════════╡
│ /mnt/datastore/fs_critical_backup    │ /dev/disk/by-uuid/ebd45c3d-5e0f-420a-8422-93c93a5b727d │ ext4       │ defaults │
├──────────────────────────────────────┼────────────────────────────────────────────────────────┼────────────┼──────────┤

# Now, I don't want it anymore so let's delete it
# List mount unit files
$ sudo systemctl list-unit-files -t mount
UNIT FILE                       STATE     VENDOR PRESET
-.mount                         generated -         
boot.mount                      generated -         
...
mnt-datastore-fs_critical_backup.mount enabled   enabled

# Delete the unit files
$ sudo systemctl disable mnt-datastore-fs_critical_backup.mount

# Delete the service
$ sudo  rm /etc/systemd/system/mnt-datastore-fs_critical_backup.mount

# Now I format the disk (not sure it is needed)
$ sudo proxmox-backup-manager disk list
┌──────┬─────────┬─────┬───────────┬─────────────┬───────────────┬─────────┬────────┐
│ name │ used    │ gpt │ disk-type │        size │ model         │ wearout │ status │
╞══════╪═════════╪═════╪═══════════╪═════════════╪═══════════════╪═════════╪════════╡
│ sda  │ mounted │   0 │ hdd       │ 21474836480 │ QEMU_HARDDISK │       - │ passed │
├──────┼─────────┼─────┼───────────┼─────────────┼───────────────┼─────────┼────────┤
│ sdb  │ mounted │   0 │ hdd       │ 34359738368 │ QEMU_HARDDISK │       - │ passed │
└──────┴─────────┴─────┴───────────┴─────────────┴───────────────┴─────────┴────────┘

$ sudo sgdisk --zap-all /dev/sdb
Warning: The kernel is still using the old partition table.
The new table will be used at the next reboot or after you
run partprobe(8) or kpartx(8)
GPT data structures destroyed! You may now partition the disk using fdisk or
other utilities.

# Reboot
$ sudo reboot

# Identify the "unused" disk. For an unknown reason, it's now "sda" which is unused.
$ sudo proxmox-backup-manager disk list
┌──────┬─────────┬─────┬───────────┬─────────────┬───────────────┬─────────┬────────┐
│ name │ used    │ gpt │ disk-type │        size │ model         │ wearout │ status │
╞══════╪═════════╪═════╪═══════════╪═════════════╪═══════════════╪═════════╪════════╡
│ sda  │ unused  │   0 │ hdd       │ 34359738368 │ QEMU_HARDDISK │       - │ passed │
├──────┼─────────┼─────┼───────────┼─────────────┼───────────────┼─────────┼────────┤
│ sdb  │ mounted │   0 │ hdd       │ 21474836480 │ QEMU_HARDDISK │       - │ passed │
└──────┴─────────┴─────┴───────────┴─────────────┴───────────────┴─────────┴────────┘

# Initialize the unused disk
$ sudo proxmox-backup-manager disk initialize sda
initialize disk sda
TASK OK

# Finally try to create the same FS name but it fails
$ sudo proxmox-backup-manager disk fs create fs_critical_backup --disk sda --filesystem ext4
Error: path "/mnt/datastore/fs_critical_backup" already exists


So What I am doing wrong or forgetting here?
Is there an easiest way of deleting a FS (Directory)? Is there a way of doing it inside the GUI?

I am running on Debian Bullseye : Linux pbs 5.10.0-21-amd64 #1 SMP Debian 5.10.162-1 (2023-01-21) x86_64 GNU/Linux
Proxmox Backup Server version : 2.3.3

Thanks for your help.

Cheers
 
Last edited:
Did you try to delete the empty mountpoint? sudo rm /mnt/datastore/fs_critical_backup after unmounting the filesystem and wiping the disk?
 
Nice one, that did the trick.

Thanks!

Here is the full procedure :


Bash:
# List available disk
$ sudo proxmox-backup-manager disk list
┌──────┬─────────┬─────┬───────────┬─────────────┬───────────────┬─────────┬────────┐
│ name │ used    │ gpt │ disk-type │        size │ model         │ wearout │ status │
╞══════╪═════════╪═════╪═══════════╪═════════════╪═══════════════╪═════════╪════════╡
│ sda  │ mounted │   0 │ hdd       │ 21474836480 │ QEMU_HARDDISK │       - │ passed │
├──────┼─────────┼─────┼───────────┼─────────────┼───────────────┼─────────┼────────┤
│ sdb  │ unused  │   0 │ hdd       │ 34359738368 │ QEMU_HARDDISK │       - │ passed │
└──────┴─────────┴─────┴───────────┴─────────────┴───────────────┴─────────┴────────┘

# Initialize the desired disk
$ sudo proxmox-backup-manager disk initialize sdb
initialize disk sdb
TASK OK

# Create a FS on the disk
$ sudo proxmox-backup-manager disk fs create fs_critical_backup --disk sdb --filesystem ext4
Chunkstore create: 1%
Chunkstore create: 2%
...
Chunkstore create: 98%
Chunkstore create: 99%
TASK OK

# Check that the FS is correctly created
$ sudo proxmox-backup-manager disk fs list
┌──────────────────────────────────────┬────────────────────────────────────────────────────────┬────────────┬──────────┐
│ path                                 │ device                                                 │ filesystem │ options  │
╞══════════════════════════════════════╪════════════════════════════════════════════════════════╪════════════╪══════════╡
│ /mnt/datastore/fs_critical_backup    │ /dev/disk/by-uuid/ebd45c3d-5e0f-420a-8422-93c93a5b727d │ ext4       │ defaults │
├──────────────────────────────────────┼────────────────────────────────────────────────────────┼────────────┼──────────┤

# Now, I don't want it anymore so let's delete it
# List mount unit files
$ sudo systemctl list-unit-files -t mount
UNIT FILE                       STATE     VENDOR PRESET
-.mount                         generated -         
boot.mount                      generated -         
...
mnt-datastore-fs_critical_backup.mount enabled   enabled

# Delete the unit files
$ sudo systemctl disable mnt-datastore-fs_critical_backup.mount

# Delete the service
$ sudo  rm /etc/systemd/system/mnt-datastore-fs_critical_backup.mount

# Now I format the disk (not sure it is needed)
$ sudo proxmox-backup-manager disk list
┌──────┬─────────┬─────┬───────────┬─────────────┬───────────────┬─────────┬────────┐
│ name │ used    │ gpt │ disk-type │        size │ model         │ wearout │ status │
╞══════╪═════════╪═════╪═══════════╪═════════════╪═══════════════╪═════════╪════════╡
│ sda  │ mounted │   0 │ hdd       │ 21474836480 │ QEMU_HARDDISK │       - │ passed │
├──────┼─────────┼─────┼───────────┼─────────────┼───────────────┼─────────┼────────┤
│ sdb  │ mounted │   0 │ hdd       │ 34359738368 │ QEMU_HARDDISK │       - │ passed │
└──────┴─────────┴─────┴───────────┴─────────────┴───────────────┴─────────┴────────┘

$ sudo sgdisk --zap-all /dev/sdb
Warning: The kernel is still using the old partition table.
The new table will be used at the next reboot or after you
run partprobe(8) or kpartx(8)
GPT data structures destroyed! You may now partition the disk using fdisk or
other utilities.

# Reboot
$ sudo reboot

# Delete the empty mount point
sudo rm -R /mnt/datastore/fs_critical_backup

# Identify the "unused" disk. For an unknown reason, it's now "sda" which is unused.
$ sudo proxmox-backup-manager disk list
┌──────┬─────────┬─────┬───────────┬─────────────┬───────────────┬─────────┬────────┐
│ name │ used    │ gpt │ disk-type │        size │ model         │ wearout │ status │
╞══════╪═════════╪═════╪═══════════╪═════════════╪═══════════════╪═════════╪════════╡
│ sda  │ unused  │   0 │ hdd       │ 34359738368 │ QEMU_HARDDISK │       - │ passed │
├──────┼─────────┼─────┼───────────┼─────────────┼───────────────┼─────────┼────────┤
│ sdb  │ mounted │   0 │ hdd       │ 21474836480 │ QEMU_HARDDISK │       - │ passed │
└──────┴─────────┴─────┴───────────┴─────────────┴───────────────┴─────────┴────────┘

# Initialize the unused disk
$ sudo proxmox-backup-manager disk initialize sda
initialize disk sda
TASK OK

# Recreate your File System
$ sudo proxmox-backup-manager disk fs create fs_critical_backup --disk sda --filesystem ext4
create datastore 'fs_critical_backup' on disk sda
TASK OK
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!