Подключение нового диска в Linux (Debian)

Материал из wiki.my-comp.net

Подключаем новый диск и начинаем его использовать.

Просмотр состояния партиций[править]

root@web:~# fdisk -l

Disk /dev/sda: 320.1 GB, 320072933376 bytes
255 heads, 63 sectors/track, 38913 cylinders, total 625142448 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000853f4

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048   609425407   304711680   83  Linux
/dev/sda2       609427454   625141759     7857153    5  Extended
/dev/sda5       609427456   625141759     7857152   82  Linux swap / Solaris

Disk /dev/sdc: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders, total 976773168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x00000000

Disk /dev/sdc doesn't contain a valid partition table

Disk /dev/sdb: 120.0 GB, 120034123776 bytes
255 heads, 63 sectors/track, 14593 cylinders, total 234441648 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x1d6de9d2

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1              63    13671314     6835626   83  Linux
/dev/sdb2        13672446   234440703   110384129    5  Extended
/dev/sdb5        13672448   234440703   110384128   83  Linux

Мой новый диск /dev/sdc

Разметка жесткого диска[править]

root@web:~# fdisk /dev/sdc
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x4a79f7c8.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

The device presents a logical sector size that is smaller than
the physical sector size. Aligning to a physical sector (or optimal
I/O) size boundary is recommended, or performance may be impacted.

Command (m for help): m
Command action
   a   toggle a bootable flag
   b   edit bsd disklabel
   c   toggle the dos compatibility flag
   d   delete a partition
   l   list known partition types
   m   print this menu
   n   add a new partition
   o   create a new empty DOS partition table
   p   print the partition table
   q   quit without saving changes
   s   create a new empty Sun disklabel
   t   change a partition's system id
   u   change display/entry units
   v   verify the partition table
   w   write table to disk and exit
   x   extra functionality (experts only)

Command (m for help): p

Disk /dev/sdc: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders, total 976773168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x4a79f7c8

   Device Boot      Start         End      Blocks   Id  System

Command (m for help): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): p
Partition number (1-4, default 1):
Using default value 1
First sector (2048-976773167, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-976773167, default 976773167):
Using default value 976773167

Command (m for help): p

Disk /dev/sdc: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders, total 976773168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x4a79f7c8

   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1            2048   976773167   488385560   83  Linux

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

Форматирование раздела[править]

root@web:~# mkfs.ext4 /dev/sdc1
mke2fs 1.42.5 (29-Jul-2012)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
30531584 inodes, 122096390 blocks
6104819 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
3727 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
        4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,
        102400000

Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

Монтирование файловой системы[править]

Определяю UUID диска

root@web:~# blkid
/dev/sda5: UUID="85f53d06-8893-4d76-a987-700b1ad25208" TYPE="swap"
/dev/sda1: UUID="32fac9ac-3399-4936-80ac-7500b01ef2e3" TYPE="ext4"
/dev/sdb1: UUID="fea03fab-098c-4222-8f5d-1c11c4abc126" TYPE="ext3"
/dev/sdb5: UUID="4fc51f4e-7fb4-4d46-9f9d-408832d10230" TYPE="ext3"
/dev/sdc1: UUID="cf429788-434c-4c09-8804-aad9aff34f91" TYPE="ext4"

Добавляю в /etc/fstab следующие строки

# video archve during installation
UUID=cf429788-434c-4c09-8804-aad9aff34f91 /media/videos   ext4    defaults        1       1

и перемонтирую файловую систему

root@web:/etc# mount -a