132 | | An example is provided below: |
133 | | 1. Partition the drive using {{{fdisk}}}. Example shown below. |
134 | | {{{#!bash |
135 | | > fdisk /dev/sda |
136 | | Command (m for help): p |
137 | | |
138 | | Disk /dev/sda: 128.0 GB, 128035676160 bytes |
139 | | 255 heads, 63 sectors/track, 15566 cylinders, total 250069680 sectors |
140 | | Units = sectors of 1 * 512 = 512 bytes |
141 | | Sector size (logical/physical): 512 bytes / 512 bytes |
142 | | I/O size (minimum/optimal): 512 bytes / 512 bytes |
143 | | Disk identifier: 0x00000000 |
144 | | |
145 | | Device Boot Start End Blocks Id System |
146 | | |
147 | | Command (m for help): n |
148 | | Partition type: |
149 | | p primary (0 primary, 0 extended, 4 free) |
150 | | e extended |
151 | | Select (default p): p |
152 | | Partition number (1-4, default 1): 1 |
153 | | First sector (2048-250069679, default 2048): |
154 | | Using default value 2048 |
155 | | Last sector, +sectors or +size{K,M,G} (2048-250069679, default 250069679): |
156 | | Using default value 250069679 |
157 | | |
158 | | Command (m for help): p |
159 | | |
160 | | Disk /dev/sda: 128.0 GB, 128035676160 bytes |
161 | | 255 heads, 63 sectors/track, 15566 cylinders, total 250069680 sectors |
162 | | Units = sectors of 1 * 512 = 512 bytes |
163 | | Sector size (logical/physical): 512 bytes / 512 bytes |
164 | | I/O size (minimum/optimal): 512 bytes / 512 bytes |
165 | | Disk identifier: 0x00000000 |
166 | | |
167 | | Device Boot Start End Blocks Id System |
168 | | /dev/sda1 2048 250069679 125033816 83 Linux |
169 | | |
170 | | Command (m for help): w |
171 | | The partition table has been altered! |
172 | | |
173 | | Calling ioctl() to re-read partition table. |
174 | | Syncing disks. |
175 | | root@linaro-alip:~# |
176 | | }}} |
177 | | 2. Format the drive using |
178 | | {{{#!bash |
179 | | mkfs.ext4 /dev/sda1 |
180 | | }}} |
181 | | 3. Mount the drive |
182 | | {{{#!bash |
183 | | mkdir /mnt/disk |
184 | | root@OpenWrt:/# mount -t ext4 /dev/sda1 /mnt/disk |
185 | | [ 344.374329] EXT4-fs (sda1): mounted filesystem with ordered data mode. Opts: (null) |
186 | | }}} |
187 | | 4. Verify disk size (see {{{/dev/sda1}}} as the last item in the list below) |
188 | | {{{#!bash |
189 | | root@OpenWrt:/# df -h |
190 | | Filesystem Size Used Available Use% Mounted on |
191 | | rootfs 1.8G 16.3M 1.8G 1% / |
192 | | ubi0:rootfs 1.8G 16.3M 1.8G 1% / |
193 | | tmpfs 251.2M 132.0K 251.1M 0% /tmp |
194 | | tmpfs 512.0K 0 512.0K 0% /dev |
195 | | /dev/sda1 117.2G 59.6M 111.2G 0% /mnt/disk |
196 | | }}} |
| 132 | See [wiki:linux/blockdev linux/blockdev] for a detailed explanation with examples |