How to partition bigger than 2TB disk with GPT and ext4

bROTHER

Occasional Visitor
Now seems straightforward, but I tried many, many ways to finally get here.

Well, you just bought a 4TB disk which as you may know is the max size the router can handle (https://event.asus.com/2009/networks/disksupport/).
You do want to use the bigger partition you may get to simply use.
You want ext4 and journaling to get max performance.
You use a friendly enclosure for the router (WD Passport Elements).

The main problem is that if you partition the disk outside the router (Mini Tool, Linux live CD, etc) you'll probably end with file system extensions the router would not understand and would refuse to use. The error you get in syslog is something like "unsupported optional features".
To be on the safe & easy side you need to do the formatting inside the router.
But fdisk does not understands GPT so this seems to be a no way out road.
This is not a step by step guide. These are some of my notes from that days I was struggling with this. Command outputs may appear incoherent among them because of many changes I made. Just read to the end and then make your own plan of action.
What you need: Your new BIG disk, your Merlin-powered router (AC68U here), a flash drive, patience.
What you should at least have heard of: Entware environment, Swaping, basics from partitioning and formatting, devices in Linux. You'll find plenty of info in this forum about these subjects. Also, you may have clear at this point the right choices for you (FS type, Swap type, Use intended, etc.)
Let's go!

Entware does have a fdisk cousin that handles GPT: gdisk
So:
1. Ready first your flash drive with two partitions, one for Entware and one for swap . Or use a swap file, whichever you prefer. Feel free to search around on how to set and use swap.
2. Install Entware. I you use Optware you need to uninstall it or eject the drive hosting it first.
Code:
[email protected]:/tmp/home/root# entware-setup.sh
    Info:  This script will guide you through the Entware installation.
    Info:  Script modifies "entware" folder only on the chosen drive,
    Info:  no other data will be changed. Existing installation will be
    Info:  replaced with this one. Also some start scripts will be installed,
    Info:  the old ones will be saved on Entware partition with name
    Info:  like /tmp/mnt/sda1/jffs_scripts_backup.tgz
   …
3. Install gdisk from Entware repo. This will install to a mounted disk (the flash drive). It will create scripts that run every time you re-mount that disk. That's why you cannot have Entware and Optware at the same time.
Code:
[email protected]:/tmp/home/root# opkg install gdisk
   Installing gdisk (1.0.4-1) to root...
   Downloading http://bin.entware.net/armv7sf-k2.6/gdisk_1.0.4-1_armv7-2.6.ipk
   Installing libuuid (2.32.1-1) to root...
   Downloading http://bin.entware.net/armv7sf-k2.6/libuuid_2.32.1-1_armv7-2.6.ipk
   Configuring libuuid.
   Configuring gdisk.
4. Connect your BIG new disk and partition it with gdisk. You may need to check in the syslog the path assigned (/dev/sd?)

Code:
[email protected]:/tmp/home/root# gdisk /dev/sdb
   GPT fdisk (gdisk) version 1.0.4
   Partition table scan:
     MBR: protective
     BSD: not present
     APM: not present
     GPT: present
   Found valid GPT with protective MBR; using GPT.
   Command (? for help): ?
   b       back up GPT data to a file
   c       change a partition's name
   d       delete a partition
   i       show detailed information on a partition
   l       list known partition types
   n       add a new partition
   o       create a new empty GUID partition table (GPT)
   p       print the partition table
   q       quit without saving changes
   r       recovery and transformation options (experts only)
   s       sort partitions
   t       change a partition's type code
   v       verify disk
   w       write table to disk and exit
   x       extra functionality (experts only)
   ?       print this menu
   Command (? for help): p
   Disk /dev/sdb: 7813969920 sectors, 3.6 TiB
   Model: Elements 25A1
   Sector size (logical/physical): 512/4096 bytes
   Disk identifier (GUID): 49C52300-56CF-03A9-C048-71D2B355EA00
   Partition table holds up to 128 entries
   Main partition table begins at sector 2 and ends at sector 33
   First usable sector is 34, last usable sector is 7813969886
   Partitions will be aligned on 2048-sector boundaries
   Total free space is 7813969853 sectors (3.6 TiB)
   Number  Start (sector)    End (sector)  Size      Code  Name
4.1. First partition. I leave here a 1 GB for a future swap. "L" shows the available FS types (not shown here). "8200" is the code for swap partition.
Code:
Command (? for help): n
   Partition number (1-128, default 1):
   First sector (34-7813969886, default = 2048) or {+-}size{KMGTP}:
   Last sector (2048-7813969886, default = 7813969886) or {+-}size{KMGTP}: +1G
   Current type is 'Linux filesystem'
   Hex code or GUID (L to show codes, Enter = 8300): 8200
   Changed type of partition to 'Linux swap'
4.2. Check what you have done
Code:
Command (? for help): p
   Disk /dev/sdb: 7813969920 sectors, 3.6 TiB
   Model: Elements 25A1
   Sector size (logical/physical): 512/4096 bytes
   Disk identifier (GUID): 49C52300-56CF-03A9-C048-71D2B355EA00
   Partition table holds up to 128 entries
   Main partition table begins at sector 2 and ends at sector 33
   First usable sector is 34, last usable sector is 7813969886
   Partitions will be aligned on 2048-sector boundaries
   Total free space is 7811872701 sectors (3.6 TiB)
   Number  Start (sector)    End (sector)  Size      Code  Name
     1            2048         2099199   1024.0 MiB  8200  Linux swap
4.3. Second partition. Data for Torrents.
Code:
Command (? for help): n
   Partition number (2-128, default 2):
   First sector (34-7813969886, default = 2099200) or {+-}size{KMGTP}:
   Last sector (2099200-7813969886, default = 7813969886) or {+-}size{KMGTP}:
   Current type is 'Linux filesystem'
   Hex code or GUID (L to show codes, Enter = 8300):
   Changed type of partition to 'Linux filesystem'
4.4. Check what you have done
Code:
Command (? for help): p
   Disk /dev/sdb: 7813969920 sectors, 3.6 TiB
   Model: Elements 25A1
   Sector size (logical/physical): 512/4096 bytes
   Disk identifier (GUID): 49C52300-56CF-03A9-C048-71D2B355EA00
   Partition table holds up to 128 entries
   Main partition table begins at sector 2 and ends at sector 33
   First usable sector is 34, last usable sector is 7813969886
   Partitions will be aligned on 2048-sector boundaries
   Total free space is 2014 sectors (1007.0 KiB)
   Number  Start (sector)    End (sector)  Size      Code  Name
     1            2048         2099199   1024.0 MiB  8200  Linux swap
     2        2099200      7813969886   3.6 TiB    8300  Linux filesystem
4.5. Rename partitions & check again
Code:
Command (? for help): c
   Partition number (1-2): 1
   Enter name: SWAP
   Command (? for help): c
   Partition number (1-2): 2
   Enter name: Data
   Command (? for help): p
   Disk /dev/sdb: 7813969920 sectors, 3.6 TiB
   Model: Elements 25A1
   Sector size (logical/physical): 512/4096 bytes
   Disk identifier (GUID): 49C52300-56CF-03A9-C048-71D2B355EA00
   Partition table holds up to 128 entries
   Main partition table begins at sector 2 and ends at sector 33
   First usable sector is 34, last usable sector is 7813969886
   Partitions will be aligned on 2048-sector boundaries
   Total free space is 2014 sectors (1007.0 KiB)
   Number  Start (sector)    End (sector)  Size      Code  Name
     1            2048         2099199   1024.0 MiB  8200  SWAP
     2        2099200      7813969886   3.6 TiB    8300  Data
4.6. Check for problems. Here I got several issues due to my multiple attempts to format this device before. I solved all of them
Code:
Command (? for help): v
   Problem: The secondary header's self-pointer indicates that it doesn't reside
   at the end of the disk. If you've added a disk to a RAID array, use the 'e'
   option on the experts' menu to adjust the secondary header's and partition
   table's locations.
   Problem: main GPT header's current LBA pointer (1) doesn't
   match the backup GPT header's alternate LBA pointer(7813969919).
   Problem: main GPT header's backup LBA pointer (7813969919) doesn't
   match the backup GPT header's current LBA pointer (1).
   The 'e' option on the experts' menu may fix this problem.
   Problem: The backup partition table overlaps the backup header.
   Using 'e' on the experts' menu may fix this problem.
   Identified 4 problems!
4.7. Don't be afraid of messing here. You can always start over. After several options fiddling with the expert menu I got a clean partition table. Then write changes to disk:
Code:
   Recovery/transformation command (? for help): v
   No problems found. 2014 free sectors (1007.0 KiB) available in 1
   segments, the largest of which is 2014 (1007.0 KiB) in size.
   Recovery/transformation command (? for help): x
   Expert command (? for help): w
   Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
   PARTITIONS!!
   Do you want to proceed? (Y/N): Y
   OK; writing new GUID partition table (GPT) to /de
v/sdb.
   The operation has completed successfully.

Limitation of 10000 chars --> Go on with next post reply.
 
Last edited:

bROTHER

Occasional Visitor
5. Remounting the disk should show now two partitions, /dev/sdb1 and /dev/sdb2
We may format now them. Keep in mind that this is a high intensive task and you may run out of memory. You'll need to use the swap partition or swap file you set up in the first step to avoid this issue.
Formating:
Code:
   [email protected]:/tmp/home/root# mke2fs -t ext4 -O has_journal /dev/sdb2
   mke2fs 1.42.13 (17-May-2015)
   Creating filesystem with 976483835 4k blocks and 244121600 inodes
   Filesystem UUID: fa3d35f4-5af9-47bb-bbe2-b631bfc9b435
   Superblock backups stored on blocks:
          32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
          4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,
          102400000, 214990848, 512000000, 550731776, 644972544
   Allocating group tables: done
   Writing inode tables:  4074/29800
After a while:
Code:
Writing inode tables: done
   Creating journal (32768 blocks): done
   Writing superblocks and filesystem accounting information: done
I'm not dealing with the swap partition of the BIG disk here. I still do not use it today (I prefer the one in the flash drive).
6.Extract disk and reconnect again. Syslog should show something like:
Code:
   Jan 14 07:37:03 kernel: scsi 5:0:0:0: Direct-Access     WD      Elements 25A1    1013 PQ: 0 ANSI: 6
   Jan 14 07:37:03 kernel: sd 5:0:0:0: Attached scsi generic sg1 type 0
   Jan 14 07:37:05 Samba_Server: smb daemon is stopped
   Jan 14 07:37:05 kernel: sd 5:0:0:0: [sdb] Spinning up disk....
   Jan 14 07:37:05 kernel: gro disabled
   Jan 14 07:37:05 Timemachine: daemon is stopped
   Jan 14 07:37:05 kernel: .
   Jan 14 07:37:05 kernel: gro enabled with interval 2
   Jan 14 07:37:06 Samba_Server: daemon is started
   Jan 14 07:37:08 kernel: ...ready
   Jan 14 07:37:08 kernel: sd 5:0:0:0: [sdb] Very big device. Trying to use READ CAPACITY(16).
   Jan 14 07:37:08 kernel: sd 5:0:0:0: [sdb] 7813969920 512-byte logical blocks: (4.00 TB/3.63 TiB)
   Jan 14 07:37:08 kernel: sd 5:0:0:0: [sdb] 4096-byte physical blocks
   Jan 14 07:37:08 kernel: sd 5:0:0:0: [sdb] Write Protect is off
   Jan 14 07:37:08 kernel: sd 5:0:0:0: [sdb] Assuming drive cache: write through
   Jan 14 07:37:08 kernel: sd 5:0:0:0: [sdb] Very big device. Trying to use READ CAPACITY(16).
   Jan 14 07:37:08 kernel: sd 5:0:0:0: [sdb] Assuming drive cache: write through
   Jan 14 07:37:08 kernel:  sdb: sdb1 sdb2 sdb3
   Jan 14 07:37:08 kernel: sd 5:0:0:0: [sdb] Very big device. Trying to use READ CAPACITY(16).
   Jan 14 07:37:08 kernel: sd 5:0:0:0: [sdb] Assuming drive cache: write through
   Jan 14 07:37:08 kernel: sd 5:0:0:0: [sdb] Attached SCSI disk
   Jan 14 07:37:11 kernel: EXT3-fs: barriers not enabled
   Jan 14 07:37:11 hotplug[8140]: USB ext3 fs at /dev/sdb2 mounted on /tmp/mnt/Entware(1)
   Jan 14 07:37:11 kernel: kjournald starting.  Commit interval 5 seconds
   Jan 14 07:37:11 kernel: EXT3-fs (sdb2): using internal journal
   Jan 14 07:37:11 kernel: EXT3-fs (sdb2): mounted filesystem with ordered data mode
   Jan 14 07:37:11 usb: USB ext3 fs at /dev/sdb2 mounted on /tmp/mnt/Entware(1).
   Jan 14 07:37:11 custom_script: Running /jffs/scripts/post-mount (args: /tmp/mnt/Entware(1) ) - max timeout = 120s
   Jan 14 07:37:11 rc_service: hotplug 8140:notify_rc restart_nasapps
   Jan 14 07:37:11 iTunes: daemon is stopped
   Jan 14 07:37:11 FTP_Server: daemon is stopped
   Jan 14 07:37:12 Samba_Server: smb daemon is stopped
   Jan 14 07:37:12 kernel: gro disabled
   Jan 14 07:37:13 Timemachine: daemon is stopped
   Jan 14 07:37:13 kernel: gro enabled with interval 2
   Jan 14 07:37:14 Samba_Server: daemon is started
   Jan 14 07:37:16 hotplug[8138]: USB ext4 fs at /dev/sdb3 mounted on /tmp/mnt/sdb3
   Jan 14 07:37:16 usb: USB ext4 fs at /dev/sdb3 mounted on /tmp/mnt/sdb3.
   Jan 14 07:37:16 kernel: EXT4-fs (sdb3): mounted filesystem with ordered data mode. Opts: user_xattr
   Jan 14 07:37:16 custom_script: Running /jffs/scripts/post-mount (args: /tmp/mnt/sdb3 ) - max timeout = 120s
   Jan 14 07:37:16 rc_service: hotplug 8138:notify_rc restart_nasapps
   Jan 14 07:37:16 iTunes: daemon is stopped
   Jan 14 07:37:16 FTP_Server: daemon is stopped
   Jan 14 07:37:18 Samba_Server: smb daemon is stopped
   Jan 14 07:37:18 kernel: gro disabled
   Jan 14 07:37:18 Timemachine: daemon is stopped
   Jan 14 07:37:18 kernel: gro enabled with interval 2
   Jan 14 07:37:19 Samba_Server: daemon is started
7. DF can show free space:
Code:
[email protected]:/tmp/home/root# df -h
   Filesystem                Size      Used Available Use% Mounted on
   /dev/root                34.0M     34.0M         0 100% /
   devtmpfs                124.8M         0    124.8M  0% /dev
   tmpfs                  124.9M   1008.0K    123.9M  1% /tmp
   /dev/mtdblock4          62.8M      1.7M     61.0M  3% /jffs
   /dev/sda2                13.7G     45.4M     12.9G  0% /tmp/mnt/Datos
   /dev/sdb3                 3.6T    196.0M      3.4T   0% /tmp/mnt/sdb3
8. Fdisk can show now your partitions:
Code:
[email protected]:/tmp/home/root# fdisk -l
   (…)
   Disk /dev/sdb: 4294967295 sectors, 2047G
   Logical sector size: 512
   Disk identifier (GUID): 49c52300-56cf-03a9-c048-71d2b355ea00
   Partition table holds up to 128 entries
   First usable sector is 34, last usable sector is 7813969886
   Number  Start (sector)    End (sector)  Size      Code  Name
     1            2048         2099199       1024M  0700  futuro_swap
     2         2099200         4196351       1024M  0700  Entware
      3         4196352      7813969886       3723G  0700  Torrent
From the above output you may note that there is another extra partition. I told you, these are only notes from my work and not actually a step by step guide.
I finally set 3 partitions on the BIG disk instead of the 2 shown in step 3:
Swap - Swap partion to use some day.
Entware - Final environment for Entware.
Data - A bunch of space for Torrents.
To finish, I reformatted the flash drive (which held the Entware and gdisk for the BIG disk provisioning) and made two partitions:
Swap - The real swap partition I'm still using today.
Data- Empty space.
Then I installed definitely Entware on the BIG disk partition with the same name, installed gdisk and Transmission.
Then I configured Transmission parameters to the new paths (I had formerly Transmission with an Optware environment).
Hope this saves you a lot of hassle.
Regards.
 

EmeraldDeer

Very Senior Member
If you use "tune2fs -l" against the partitions, what are your settings for "Maximum mount count" and "Check interval"?
 

ColinTaylor

Part of the Furniture
Nice work. Maybe we’ll see this automated in a future AMTM @thelonelycoder
The problem I foresee with putting it in AMTM is that it depends on Entware. AMTM is nice (IMHO) precisely because it doesn't require Entware. If we were to assume that Entware-dependent functions are OK, then we could have easily written the current fd option using parted instead of fdisk. (It would have made life much easier :D:rolleyes:)
 

L&LD

Part of the Furniture
ColinTaylor, at the same time, amtm is a gateway drug to the other excellent scripts available. Most of those (Diversion is the obvious one) require Entware anyway. :D
 

ColinTaylor

Part of the Furniture
ColinTaylor, at the same time, amtm is a gateway drug to the other excellent scripts available. Most of those (Diversion is the obvious one) require Entware anyway. :D
Indeed, but it's a bit "chicken and egg" though. People might be plugging in their one and only USB device for the first time, wanting to format it so that they can install Entware on it.
 

thelonelycoder

Part of the Furniture
Indeed, but it's a bit "chicken and egg" though. People might be plugging in their one and only USB device for the first time, wanting to format it so that they can install Entware on it.
Or have Entware installed and wanting to format that only device with options only available in Entware.
amtm stays at the basic level. It can already do more than most ever need.
 

EmeraldDeer

Very Senior Member
-1 and 0 <none> respectively for each of them
So I think that means they will never be automatically full checked by e2fsck. I have them set to 1 and 1d so essentially there will be full checks by e2fsck almost every boot. However, I am using a USB SSD.

Even though the idea has not had traction, I emphatically recommend Entware partitions no larger than 3 GB. I have a 3 GB partition and it takes less than three seconds for a full e2fsck. I suspect that your 1 GB partition on a HDD may take less than ten seconds. However, if it actually takes more than 30 seconds, then perhaps it is best to never do it. I previously had an all-in-one 500 GB partition which took over two minutes to full check. That default twentieth boot full check was a real mess.

My other partition is a 100 GB Samba partition. It takes about 30 seconds to full check e2fsck. Samba seems to handle this gracefully and behaves normally when the filesystem finally get mounted. Samba might be OK even if would take a lot longer. I do not have a guess as to how long a full check e2fsck lasts for an almost 4 TB partition on a HDD. Perhaps it would never be worth it.
 

bROTHER

Occasional Visitor
Hi,

It is always a good advice to periodically check disks, no matter how big they are.
In my case I need a BIG disk and need to use the larger partition possible, hence the quest for GPT.
Scheduling check on boot delays the services start. That you should take into account for the remaining scripts that launch upon mounting.
Therefore for me it's safer to check manually from time to time, stopping services, etc.

Regards.
 

ColinTaylor

Part of the Furniture
MBR can only support disk up to 2TB at most, so if you want to convert an over 2TB disk to GPT, the nontraditional ways like Command Prompt and Disk Management won't fulfill this task. All you need is a free MBR to GPT converter, like AOMEI Partition Assistant, which allows you to convert a large hard disk to GPT disks and create ext4 partition on it.
I think you've missed the entire point of this thread, which is to not use a Windows based utility. See post #1.

For people who want a Windows partitioning tool other free options are available like EaseUS or MiniTool.
 

Zonkd

Very Senior Member
MBR can only support disk up to 2TB at most, so if you want to convert an over 2TB disk to GPT, the nontraditional ways like Command Prompt and Disk Management won't fulfill this task. All you need is a free MBR to GPT converter, like AOMEI Partition Assistant, which allows you to convert a large hard disk to GPT disks and create ext4 partition on it.

News, ad, news, ad, n... wait, no that's an ad for catfood.



 
Similar threads

Similar threads

Latest threads

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top