Table of Contents
If you want to send us your comments, please do so. Thanks
More on comments
Formatting
Partitions and filesystmes
Before you can format a partition it needs to exist. See these pages for more information
See Partitions
See Filesystem on how to set up an new / empty harddisk and the partitions
See Check filesystem on how to check and repair a filesystem
Check ext4 filesystem
fsck -C -r -t ext4 -l -V /dev/sdxn
Check for bad blocks (do not use the badblocks command, use e2fsck, see the Important note: on the badblocks man page)
e2fsck -c -c -f -C 0 -v /dev/sdxn
-c -c does a read write test. Do not do this on SSD's. Then only use one -c
-C 0 shows the progress. 0 is the file descriptor
Ext4 without journal
Advantages
- Avoids writing to the journal on the drive when used on an SSD
- Saves harddisk space. Initially very little. On a 2TB drive about 0.12 GB
- Might speed up write actions since the journal doesn't have to be written
mkfs.ext4 commands
mkfs option | Function | Remark |
---|---|---|
-v | verbose | |
-c | check for bad blocks. Read only test. This can take a long time | |
-c -c | check for bad blocks. Read write test. This can take a long time. About four times as long as with a single -c | |
-F | Force mke2fs to create a file system | |
-I | add this option if partitioning does not work | |
-t fs-type | Specify the filesystem type (i.e., ext2, ext3, ext4, etc.) that is to be created. | |
-L labelname | label | |
-m | reserved-blocks-percentage | Default is 5%. Lowering this value saves space. This can come handy when using a drive just as backup. The value can also be a fraction of a percent like 0.2% (values are rounded down to on decimal after the point) |
-n | See what would be done without doing it | |
-N | number-of-inodes | |
-O feature[,…] | Create a filesystem with the given features (filesystem options), overriding the default filesystem options | |
-O ^64bit | Create a 32 bit filesystem. This can avoid boot issues | |
-O has_journal | feature: Create an ext3 journal (as if using the -j option). Maybe the manpage needs an update for ext4 | |
-O extent | feature: extents is a much more efficient encoding which speeds up filesystem access, especially for large files | |
^ | feature: To disable a feature, simply prefix the feature name with a caret (^) character | |
device | The device to be formatted like /dev/sdx |
Format with mkfs.ext4
Make sure the device is unmounted
mkfs.ext4 -v -c -O extent -O has_journal -t ext4 -L new-volume-label /dev/sdx1
After formatting journaling can be disabled with
tune2fs -O ^has_journal /dev/sdx
Errors
mkfs.ext4: invalid blocks '/dev/sdx' on device 'Drivelabel'
Probable causes
- A partition table needs to be made on the drive.
- An empty partition needs to be made
- The partition type has to be set to something like ext4
Format a partition with ext2
mkfs.ext2 -L new-volume-label /dev/sdx1
Options that might be usefull. In the example below space is saved in case there will be only large files on the harddisk
Command | Example |
---|---|
-L new-volume-label | -L Debian9 |
-m reserved-blocks-percentage | -m 0.1 |
-N number-of-inodes | -N 100 |
-T usage-type[,…] | -T largefile |
-v verbose | -v |
mkfs.ext2 -L TheLabel -N 100 -T largefile -m 0.1 /dev/sdx1
Source: Formatting an ext2/3 partition and the mkfs.ext2 man page
FAT filesystem
mkdosfs, mkfs.fat, mkfs.msdos and mkfs.vfat are the same program
Check vfat filesystem
Some options of dosfsck
-a | Automatically repair the filesystem |
-l | List path names of files being processed |
-r | Interactively repair the filesystem |
-t | Mark unreadable clusters as bad |
-v | Verbose mode |
-V | Perform a verification pass |
-w | Write changes to disk immediately |
Example:
dosfsck -w -r -l -a -v -V -t /dev/sdxn
VFAT number of files
The rootfolder kan hold 512 files with a 8.3 (characters) filename. If long filenames are used this number is reduced
Sub-directories do not have this limitation
See What is the difference between vfat and fat32 file systems for more information
Format an USBdrive with fat32
Do
Command | Remark |
---|---|
umound [path to the moudted drive] | Unmount the USBdrive |
fdisk -l | |
dosfsck -vV /dev/sdxn | Check the filesystem, verbose and verification |
mkdosfs -F 32 -n TheLabel -v -I /dev/drive | Format the drive |
Example:
mkdosfs -F 32 -n TheLabel -v -I /dev/sdd
When running Windows
you can use GRC's Initdisk
Format an USBdrive with ntfs
Unmount the USBdrive
fdisk -l e2fsck -c -c -f -C 0 /dev/sdxn (Check for bad blocks) dosfsck -vV /dev/sdxn (check the filesystem, verbose and verification) mkntfs --fast --label TheVolumeLabelOfYourChoice --verbose /dev/sdx1
Example:
mkntfs --fast --label Thelabel --verbose /dev/sdd1
Mount with (with only ntfs an Input/output error can occur)
mount -t ntfs-3g /dev/sdx1 /mnt/mountpoint/
For mount errors see Mount
SDcard
Do as root
Format with ext4
mkfs -t ext4 /dev/sdx1
Format with the FAT filesystem
Choose -F 32 for SDcards larger that 1GB
mkdosfs -v -c -F 16 -I -n DRIVELABEL /dev/sdx1
Remove the card and reinsert it.
Check with blkid if the card is detected by the system.
Mount it and check if you can write and read it.
Format with ExFAT
Over ExFAT
Some options
--boundary-align=alignment Important, see manpage
--cluster-size=size Important, see manpage
--full-format Zeros the entire disk device while creating the exFAT filesystem
--volume-label=label
--verbose
As root do for a 16 GB SDcard
mkfs.exfat --boundary-align=4MiB --cluster-size=32kiB --volume-label=LABEL --verbose /dev/sdxn
Diskette
Do, as root:
Command | Remark |
---|---|
umound [path to the moudted diskttte] | Unmount the diskette |
fdisk -l | Check if the diskette drive is present |
dosfsck -vV /dev/sdx | Check the filesystem, verbose and verification |
mkdosfs -F 12 -n THELABEL -v /dev/sdx | Format the drive. Only use capital letters for the label |
Example:
mkdosfs -F 12 -n THELABEL -v /dev/sdX
Superfloppy
A superfloppy is a removable medium with no MBR nor GPT. The entire medium is treated as a single partition
Examples:
- Floppy disk drives
- CD-ROM
- DVD-ROM
Read and change the label
Do as root
ext2/ext3/ext4 partitions
Show the label
e2label /dev/sdx5
Set a new label
e2label /dev/sdx2 TheNewLabel
vfat partitions
The program can be found in the Dosfstools package Show the label
dosfslabel /dev/sdx
Set a new label
dosfslabel /dev/sdx TheNewLabel
Or use
fatlabel /dev/sdb TheNewLabel fatlabel -i /dev/sdb
Main subjects on this wiki: Linux, Debian, HTML, Microcontrollers, Privacy
RSS
Disclaimer
Privacy statement
Bugs statement
Cookies
Copyright © : 2014 - 2024 Webevaluation.nl and the authors
Changes reserved.