.. title: File system reminder .. slug: file-system-reminder .. date: 2017-12-25 17:51:24 UTC+01:00 .. tags: bash, filesystem .. category: blog .. link: .. description: .. type: text As I am not manipulating file system everyday, I tend to forget the useful commands, hence this reminder. .. TEASER_END Discs and filesystem ==================== Here are some useful commands to manage your discs and filesystems: - ``less /etc/mtab`` gives information about the filesystems currently mounted - ``less /etc/fstab`` gives a list of available discs and partitions; in particular, you'll find in this file discs ids (``uuid``) linked to filesystems (``/dev/sda`` or ``/dev/hda`` (``/dev/sd`` being for SCSI and SATA discs whereas ``/dev/hd`` stand for IDE discs)) - ``ls /dev/disk/by-uuid`` gives disc ids list - ``sudo dumpe2fs /dev/sda1`` provides lots of information about the given filesystem - ``sudo fdisk -l`` gives information as in ``/etc/mtab`` and ``/etc/fstab`` Reduce reserved space ===================== By default, 5% of your disk space is dedicated to priority processes and root's ``/home``. If it made sense on older machines with smaller discs, it becomes anoying now we have bigger ones. To reduce this reserved space is therefore very convenient, and very simple with ``tune2fs``, specifying the percentage of your disc you want to reserve: .. code-block:: bash tune2fs -m 1 /dev/[partition] Corrupted superblock ==================== ``fsck`` can be used to check and fix a broken filesystem, and ``mke2fs`` can be used to create a filesystem; ``-j`` option is for ``ext3``: .. code-block:: bash fsck mke2fs -j -S /dev/[partition] fsck Restore a broken filesystem on a USB stick ========================================== .. code-block:: bash sudo /sbin/dosfsck -altrvV /dev/[partition] Clean-up a partition ====================== .. code-block:: bash dd if=/dev/urandom of=/dev/ bs=4096 status=progress