Apostolos\’ Daily Plate

Creating NTFS and ZFS file systems on an external USB disk

Posted in OpenIndiana by asyropoulos on Σεπτεμβρίου 8, 2017

Recently, I bought an external USB 3.0 hard disk. The disk comes pre-formatted in NTFS but for my own reasons I wanted two partitions: the first formatted in NTFS and the second formatted in ZFS. The first thing one should do is to delete all partition on the disk. To do this use a command like the following one:

# rmformat -l
Looking for devices...
     1. Logical Node: /dev/rdsk/c12t0d0p0
        Physical Node: /pci@0,0/pci1458,5004@13,2/storage@3/disk@0,0
        Connected Device: Generic- SD/MMC           1.00
        Device Type: Removable
        Bus: USB
        Size: 30,4 GB
        Label: 
# fdisk /dev/rdsk/c12t0d0p0

The first command should be used to discover the name of the device that represents your disk. Will see something like the following:

             Total disk size is 3880 cylinders
             Cylinder size is 16065 (512 byte) blocks

                                               Cylinders
      Partition   Status    Type          Start   End   Length    %
      =========   ======    ============  =====   ===   ======   ===
          1                 IFS: NTFS         0  1939    1940     50

SELECT ONE OF THE FOLLOWING:
   1. Create a partition
   2. Specify the active partition
   3. Delete a partition
   4. Change between Solaris and Solaris2 Partition IDs
   5. Edit/View extended partitions
   6. Exit (update disk configuration and exit)
   7. Cancel (exit without updating disk configuration)
Enter Selection: 

Now press 3 to delete the partition and when prompted press 1 and then 6 to exit. This program cannot create NTFS partitions so you
need to use parted as shown below:

# parted /dev/rdsk/c12t0d0p0
GNU Parted 1.8.8
Using /dev/rdsk/c12t0d0p0
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) mkpart                                                           
mkpart
Partition type?  primary/extended? primary                                
primary
File system type?  [ext2]? ntfs                                           
ntfs
Start? 0                                                                  
0
End? 50%                                                                  
50%
(parted) print                                                            
print
Model: Generic Ide (ide)
Disk /dev/rdsk/c12t0d0p0: 31.9GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start   End     Size    Type     File system  Flags
 1      32.3kB  16.0GB  16.0GB  primary                    

(parted) quit                                                             
quit
#

Start again fdisk to create a Solaris partition. After pressing 1 and then 1 again you can enter 50 to specify the percentage that the second partition will occupy.

             Total disk size is 3880 cylinders
             Cylinder size is 16065 (512 byte) blocks

                                               Cylinders
      Partition   Status    Type          Start   End   Length    %
      =========   ======    ============  =====   ===   ======   ===
          1                 IFS: NTFS         0  1939    1940     50
          2       Active    Solaris2       1940  3879    1940     50



SELECT ONE OF THE FOLLOWING:
   1. Create a partition
   2. Specify the active partition
   3. Delete a partition
   4. Change between Solaris and Solaris2 Partition IDs
   5. Edit/View extended partitions
   6. Exit (update disk configuration and exit)
   7. Cancel (exit without updating disk configuration)
Enter Selection: 


Partition 2 is now the active partition.

Of course you can make the first partition active.  Now let’s create an NTFS file system.

# mkntfs -s 4096 -c 4096 -S 65535 -f -v /dev/dsk/c12t0d0p1

The next thing is to modify the slice table on the Solaris partition. Start the format utility and
chose your disk. Then select «partition». You should see something like the following after pressing «p»:

Current partition table (original):
Total disk cylinders available: 14590 + 2 (reserved cylinders)

Part      Tag    Flag     Cylinders         Size            Blocks
  0 unassigned    wm       0                0         (0/0/0)             0
  1 unassigned    wm       0                0         (0/0/0)             0
  2     backup    wu       0 - 14589      447.06GB    (14590/0/0) 937553400
  3 unassigned    wm       0                0         (0/0/0)             0
  4 unassigned    wm       0                0         (0/0/0)             0
  5 unassigned    wm       0                0         (0/0/0)             0
  6 unassigned    wm       0                0         (0/0/0)             0
  7 unassigned    wm       0                0         (0/0/0)             0
  8       boot    wu       0 -     0       31.38MB    (1/0/0)         64260
  9 unassigned    wm       0                0         (0/0/0)             0

This is wrong for our purpose and we need to modify it. First press 2 and change the «backup» tag to «unassigned», make the start cylinder 0 and the size 0gb. Then press 0 and change the tag to «root», make the start cylinder 1, and enter the size. In this case it should be 447gb. After pressing «p» you should see something like the following.

partition> p   
Current partition table (unnamed):
Total disk cylinders available: 14590 + 2 (reserved cylinders)

Part      Tag    Flag     Cylinders         Size            Blocks
  0       root    wu       1 - 14589      447.03GB    (14589/0/0) 937489140
  1 unassigned    wm       0                0         (0/0/0)             0
  2 unassigned    wu       0                0         (0/0/0)             0
  3 unassigned    wm       0                0         (0/0/0)             0
  4 unassigned    wm       0                0         (0/0/0)             0
  5 unassigned    wm       0                0         (0/0/0)             0
  6 unassigned    wm       0                0         (0/0/0)             0
  7 unassigned    wm       0                0         (0/0/0)             0
  8       boot    wu       0 -     0       31.38MB    (1/0/0)         64260
  9 unassigned    wm       0                0         (0/0/0)             0

Now press «label» to write the new table onto the disk. After this you can terminate the format utility. The next step is to create the zpool

# zpool create utank /dev/dsk/c12t0d0s0

Notice that the pool is created on slice 0. We continue by creating the file system:

# zfs create utank/external

The command that follows makes sure the disk is readable by «your» user:

# chown -R apostolo:staff /utank/external/

You can copy things to folder /utank/external/. Before unplugging the disk export the zpool:

# zpool export utank

The next time just use zpool import to import the pool. That’s all!

PS I would like to thank Udo Grabowski for his comments and suggestions.

Advertisements

The (very very) long trip of a book

Posted in Χωρίς κατηγορία by asyropoulos on Σεπτεμβρίου 4, 2017

On April 13, 2017 I went to the local office of the Greek Postal Service in order to send a book to a friend who lives in Rio de Janeiro. I sent the book by registered mail so to be able to track the parcel. The following screenshot shows how long it took to arrive to London airport.

From Greece to the UK

The third line says that the parcel arrived to the UK on 19/04/2017 and «rearrived» there on 01/06/2017. Obviously, they did something extremely stupid and the parcel stayed almost 40 days at the airport. But the good news is that on 07/06/2017 the parcel was on its way to Brazil.

From the UK to Brazil

Surprisingly the book arrived to Brazil on 07/06/2017, that is, the same day. But it was delivered to my friend on 25/08/2017. This means that it took 80 days to go from Curitiba to Rio de Janeiro. The distance between the two cities is 676 Km! I just wonder what is more lousy: the Royal Mail or Correios?