2022/06/20

arch linux

arch linuxをインストールしつつLinuxの勉強
インストール時はrootでログインするのでプロンプトが#になっている

パーティション設定

fdiskによるパーテション作成

# fdisk -l
    ->インストールしたい記憶デバイス名を選択
# fdisk /dev/<device>
    -> 下記のプロンプトにコマンドを入力
Command (m for help):

fdiskコマンドのヘルプ

Command (m for help): m

Help:

  GPT
   M   enter protective/hybrid MBR

  Generic
   d   delete a partition
   F   list free unpartitioned space
   l   list known partition types
   n   add a new partition
   p   print the partition table
   t   change a partition type
   v   verify the partition table
   i   print information about a partition

  Misc
   m   print this menu
   x   extra functionality (experts only)

  Script
   I   load disk layout from sfdisk script file
   O   dump disk layout to sfdisk script file

  Save & Exit
   w   write table to disk and exit
   q   quit without saving changes

  Create a new label
   g   create a new empty GPT partition table
   G   create a new empty SGI (IRIX) partition table
   o   create a new empty DOS partition table
   s   create a new empty Sun partition table

パーティションの削除(二つあったパーティションを削除した様子)

root@archiso ~ # fdisk /dev/sda

Welcome to fdisk (util-linux 2.37.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Command (m for help): d
Partition number (1,2, default 2): 1

Partition 1 has been deleted.

Command (m for help): d
Selected partition 2
Partition 2 has been deleted.

Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.

パーティションの作成(EFI System)

Command (m for help): n
Partition number (1-128, default 1): 1
First sector (34-125045390, default 2048): 2048
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-125045390, default 125045390): +512M

Created a new partition 1 of type 'Linux filesystem' and of size 512 MiB.
Partition #1 contains a vfat signature.

Do you want to remove the signature? [Y]es/[N]o: y

The signature will be removed by a write command.

Command (m for help): t

Selected partition 1
Partition type or alias (type L to list all): 1
Changed type of partition 'Linux filesystem' to 'EFI System'.

Command (m for help): i
Selected partition 1
         Device: /dev/sda1
          Start: 2048
            End: 1050623
        Sectors: 1048576
           Size: 512M
           Type: EFI System
      Type-UUID: C12A7328-F81F-11D2-BA4B-00A0C93EC93B
           UUID: 70B9D21C-7D6D-104A-B671-67970881B2D7

パーティションの作成(Linux swap)

Command (m for help): n
Partition number (2-128, default 2): 2
First sector (1050624-125045390, default 1050624): 
Last sector, +/-sectors or +/-size{K,M,G,T,P} (1050624-125045390, default 125045390): +4G

Created a new partition 2 of type 'Linux filesystem' and of size 4 GiB.
Partition #2 contains a ext4 signature.

Do you want to remove the signature? [Y]es/[N]o: y

The signature will be removed by a write command.

Command (m for help): t
Partition number (1,2, default 2): 2
Partition type or alias (type L to list all): 19

Changed type of partition 'Linux filesystem' to 'Linux swap'.

Command (m for help): i
Partition number (1,2, default 2): 2

         Device: /dev/sda2
          Start: 1050624
            End: 9439231
        Sectors: 8388608
           Size: 4G
           Type: Linux swap
      Type-UUID: 0657FD6D-A4AB-43C4-84E5-0933C84B4F4F
           UUID: 8F2337B3-E45C-9F48-84CA-4D54326A8F34

パーティションの作成(Linux filesystem)

Command (m for help): n
Partition number (3-128, default 3): 3
First sector (9439232-125045390, default 9439232): 
Last sector, +/-sectors or +/-size{K,M,G,T,P} (9439232-125045390, default 125045390): 

Created a new partition 3 of type 'Linux filesystem' and of size 55.1 GiB.

Command (m for help): t
Partition number (1-3, default 3): 3
Partition type or alias (type L to list all): 20

Changed type of partition 'Linux filesystem' to 'Linux filesystem'.

Command (m for help): i
Partition number (1-3, default 3): 3

         Device: /dev/sda3
          Start: 9439232
            End: 125045390
        Sectors: 115606159
           Size: 55.1G
           Type: Linux filesystem
      Type-UUID: 0FC63DAF-8483-4772-8E79-3D69D8477DE4
           UUID: BB0CB271-F1BF-ED4B-AA45-35D9B890AA88

パーティション変更の書き込み

Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.

ディスクパーティション例

root@archiso ~ # fdisk -l
Disk /dev/sda: 59.63 GiB, 64023257088 bytes, 125045424 sectors
Disk model: OSC mSATA 64GB  
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: F8EAB171-87B3-4A97-9DD5-EF2F7A56C358

Device       Start       End   Sectors  Size Type
/dev/sda1     2048   1050623   1048576  512M EFI System
/dev/sda2  1050624   9439231   8388608    4G Linux swap
/dev/sda3  9439232 125045390 115606159 55.1G Linux filesystem

ディスクパーティションの確認(lablk)

root@archiso ~ # lsblk
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
loop0    7:0    0 662.7M  1 loop /run/archiso/airootfs
sda      8:0    0  59.6G  0 disk 
├─sda1   8:1    0   512M  0 part 
├─sda2   8:2    0     4G  0 part 
└─sda3   8:3    0  55.1G  0 part

ファイルシステムの構築

root@archiso ~ # mkfs.fat -F 32 /dev/sda1
mkfs.fat 4.2 (2021-01-31)

root@archiso ~ # mkswap /dev/sda2 
Setting up swapspace version 1, size = 4 GiB (4294963200 bytes)
no label, UUID=1c63a8fe-d7ce-49b8-b2b6-80176b75f994

root@archiso ~ # mkfs.ext4 /dev/sda3
mke2fs 1.46.4 (18-Aug-2021)
Discarding device blocks: done                            
Creating filesystem with 14450688 4k blocks and 3619728 inodes
Filesystem UUID: 71e2a5fa-e729-4905-8cba-830240ce2b63
Superblock backups stored on blocks: 
	32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 
	4096000, 7962624, 11239424

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

ファイルシステムのマウント

root@archiso ~ # mount /dev/sda3 /mnt
root@archiso ~ # swapon /dev/sda2
root@archiso ~ # mkdir /mnt/boot
root@archiso ~ # mount /dev/sda1 /mnt/boot

root@archiso ~ # lsblk
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
loop0    7:0    0 662.7M  1 loop /run/archiso/airootfs
sda      8:0    0  59.6G  0 disk 
├─sda1   8:1    0   512M  0 part /mnt/boot
├─sda2   8:2    0     4G  0 part [SWAP]
└─sda3   8:3    0  55.1G  0 part /mnt
sdb      8:16   1  14.5G  0 disk 
└─sdb1   8:17   1  14.5G  0 part /run/archiso/bootmnt

root@archiso ~ # mount | grep /mnt
/dev/sda3 on /mnt type ext4 (rw,relatime)
/dev/sda1 on /mnt/boot type vfat (rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro)

検索用タグ

arch, Linux, ファイルシステム, パーティション, fdisk, lsblk

参考