Formatting 128GB SD card to ext4 with gparted

26,996

Had problems with gparted running from the OS (ie not started from a "live" boot disk). Assuming you want to assign the whole drive to one ext4 partition.

Note: assuming to make a whole disk ext4 will destroy any existing data on that drive!

Try the manual method, do

   lsblk 

to visually determine where you USB drive is, ie the letter X in /dev/sdX, and the partition(s), if any, N in /dev/sdXN. Eg. /dev/sdc, /dev/sdc1, ... Replace X where relevant.

If necessary, umount whatever is mounted on that drive

   sudo umount /dev/sdXN

Then, optional, make the formatting tools "believe" the drive is blank by writing zeroes to the beginning of the flash memory (here 100 MB), to start from clean grounds. Since writing directly to the device bypasses higher level mechanisms, a sync ensures data is actually written (not only in buffers))

   sudo dd if=/dev/zero of=/dev/sdX bs=1M count=100
   sudo sync

Unplug and, after a few seconds, re-plug the drive. lsblk will show a blank disk.

Either Make a ext4 disk

If you want to assign the whole USB drive to one ext4 partition, you could simply overwrite the whole, including partition table

Command:

   sudo mkfs.ext4 -L "J Connor" /dev/sdX

and that's it. (unplug / replug)

Or Create a partition set to ext4

Or you can create one partition first, maybe smaller than 128 GB (from a "blank" disk)

Using fdisk

   sudo fdisk /dev/sdX

Commands (h for help): ensure no partition

   p

then create a partition (n), primary (p), part #1 (1), and whole size (default for first and last sectors (or set smaller size, ie lower last sector number))

   n
      p
      1
      (return for first sector default)
      (return for last sector default or set smaller size)

write the new partition table

   w

that leaves fdisk.
Note: fdisk creates a partition 83 (Linux) by default.

And create now the ext4 file system on that new partition

   sudo mkfs.ext4 -L "J Connor" /dev/sdX1

Try to unplug and replug the device - it should be mounted automatically.

Or mount it manually

   sudo mkdir /mnt/mydrive
   sudo mount /dev/sdX /mnt/mydrive

   sudo ls -l /mnt/mydrive

   drwxr-xr-x 3 root root  4096 Jan 31  9:28 ./
   drwxr-xr-x 6 root root  4096 May  9  2014 ../
   drwx------ 2 root root 16384 Jan 31  9:28 lost+found/

See also these explanations about fdisk.

Share:
26,996

Related videos on Youtube

ConnorJ
Author by

ConnorJ

Updated on September 18, 2022

Comments

  • ConnorJ
    ConnorJ almost 2 years

    I am trying to format a SanDisk 128GB SDXC card plugged into the internal SD card reader on a Toshiba Chromebook 2 running Crouton.

    When I format to ext4 using gparted the operation never completes, I have to break the operation and get a warning that I am seriuusly damaging the file system. If I then try to format to FAT 32 it gives an error message. However, when I inplug the card and reinser it, then format to FAT 32 it does it it within a minute or so.

    Are there any known problems with formating SD cards of this size on Ubuntu? Is there anyway I can get it to format to ext4? Or does it just take forever and I need to be patient and let the operation run (it's been at least ten minutes so far and doesn't appear to be doing anything)?

    Edit:

    This is what I am trying to do with the SD - is it essential to use ext4 for such an operation or would Fat32 work?

    http://ubuntuforums.org/showthread.php?t=2242850

    EDIT:

    I tried using fdisk in Chrome OS.

    I could successfully create a new partition but when I tried using mkfs.ext4 I get the same error message I get from gparted:

    /dev/mmcblk1p1 is apparently in use by the system; will not make a filesystem here!    
    

    I've Googled the error and everything seems to relate to RAID drives and the fixes get a little above my head

    EDIT

    The following is the full output from gparted

    Create Primary Partition #1 (ext4, 116.73 GiB) on /dev/mmcblk1 00:00:03 ( ERROR )

    create empty partition 00:00:02 ( SUCCESS )

    path: /dev/mmcblk1p1 start: 2048 end: 244809727 size: 244807680 (116.73 GiB) set partition type on /dev/mmcblk1p1 00:00:01 ( SUCCESS )

    new partition type: ext4 create new ext4 file system 00:00:00 ( ERROR )

    mkfs.ext4 -j -O extent -L "" /dev/mmcblk1p1

    mke2fs 1.42 (29-Nov-2011) /dev/mmcblk1p1 is apparently in use by the system; will not make a filesystem here!

    EDIT:

    Here is the output from the instructions below

    (precise)connor@localhost:~$ sudo umount /dev/mmcblk1
    [sudo] password for connor: 
    umount: /dev/mmcblk1: not mounted
    (precise)connor@localhost:~$ sudo dd if=/dev/zero of=/dev/mmcblk1 bs=1M count=100
    100+0 records in
    100+0 records out
    104857600 bytes (105 MB) copied, 15.8013 s, 6.6 MB/s
    (precise)connor@localhost:~$ sudo mkfs.ext4 -L "J Connor" /dev/mmcblk1
    mke2fs 1.42 (29-Nov-2011)
    Discarding device blocks: 4096/30601216
    

    The system just sits at this point and doesn't do anything. If I remove the SD card the chromebook reboots.

    EDIT:

    I tried again, this time a different result (sort of) - when I checked the Chrome OS file system this time the device was not mounted like last time. However I got the same error that I get from gparted:

    (precise)connor@localhost:~$ sudo umount /dev/mmcblk1
    [sudo] password for connor: 
    umount: /dev/mmcblk1: not mounted
    (precise)connor@localhost:~$ sudo dd if=/dev/zero of=/dev/mmcblk1 bs=1M count=100
    100+0 records in
    100+0 records out
    104857600 bytes (105 MB) copied, 0.171444 s, 612 MB/s
    (precise)connor@localhost:~$ sudo mkfs.ext4 -L "J Connor" /dev/mmcblk1
    mke2fs 1.42 (29-Nov-2011)
    /dev/mmcblk1 is apparently in use by the system; will not make a filesystem here!
    (precise)connor@localhost:~$
    
    • LittleByBlue
      LittleByBlue over 9 years
      isn't exfat the usual fs for SD cards? Have you tried to use parted or fdisk?
    • ConnorJ
      ConnorJ over 9 years
      Would I be able to set the SD up in the way described in the link I posted?
    • LittleByBlue
      LittleByBlue over 9 years
      see in the answer the fdisk description.