Rebuilding fstab and creating mount points

By default aptosid uses uuid in your fstab when you install.

新しく作られたパーティション(例としてsda6とsdb7)がfstabにないときや、コンソールからユーザーとしてマウントしたいとき、次のコマンドを実行します:

 ls -l /dev/disk/by-uuid

次のような表示がでます(ボールドの表示は説明のためです):

lrwxrwxrwx 1 root root 10 2007-05-27 23:42 348ea9e6-7879-4332-8d7a-915507574a80 -> ../../sda4
lrwxrwxrwx 1 root root 10 2007-05-27 23:42 610aaaeb-a65e-4269-9714-b26a1388a106 -> ../../sda2
lrwxrwxrwx 1 root root 10 2007-05-27 23:42 857c5e63-c9be-4080-b4c2-72d606435051 -> ../../sda5
lrwxrwxrwx 1 root root 10 2007-05-27 23:42 a83b8ede-a9df-4df6-bfc7-02b8b7a5f1f2 -> ../../sda1
lrwxrwxrwx 1 root root 10 2007-05-27 23:42 ad662d33-6934-459c-a128-bdf0393e0f44 -> ../../sda6

この例ではad662d33-6934-459c-a128-bdf0393e0f44がfstabに欠けている項目です。 次のステップはこのUUIDを/etc/fstabに加えることです。 rootとしてテキストエディタ(kateやkwrite)などでfstabファイルを開き:

# <device file system> <mount point>   <type>  <options>       <dump> <pass>
UUID=ad662d33-6934-459c-a128-bdf0393e0f44 /media/disk1part6 ext4	auto,users,exec	0 2

もう一つの例:

lrwxrwxrwx 1 root root 10 2007-05-28 13:18 30ebb8eb-8f22-460c-b8dd-59140274829d -> ../../sdb8
lrwxrwxrwx 1 root root 10 2007-05-28 13:18 387d6d4b-4508-4b8e-8ed2-76998f41dae4 -> ../../sdb1
rwxrwxrwx 1 root root 10 2007-05-28 13:18 7014f66f-6cdf-4fe1-83da-9cab7b6fab1a -> ../../sdb5
lrwxrwxrwx 1 root root 10 2007-05-28 13:18 8f042ead-259f-4df0-98ec-3343080396c5 -> ../../sdb6
lrwxrwxrwx 1 root root 10 2007-05-28 13:18 94B0AE63B0AE4B94 -> ../../sda2
lrwxrwxrwx 1 root root 10 2007-05-28 13:18 A61820AA18207B85 -> ../../sda1
lrwxrwxrwx 1 root root 10 2007-05-28 13:18 f28725d6-b7b5-4207-8476-36efe1a903ce -> ../../sdb9
lrwxrwxrwx 1 root root 10 2007-05-28 13:18 f855c263-2521-48d3-8ec9-d2d2b69b6635 -> ../../sda3
rwxrwxrwx 1 root root 10 2007-05-28 13:18 f9aa4027-ecdd-4a86-84e2-df2ef73fe14e -> ../../sdb7

この例ではf9aa4027-ecdd-4a86-84e2-df2ef73fe14eがfstabに欠けていてこれから加えるUUIDです:

# <device file system> <mount point>   <type>  <options>       <dump> <pass>
UUID=f9aa4027-ecdd-4a86-84e2-df2ef73fe14e /media/disk2part7 ext4	auto,users,exec	0 2

Creating new mount points

Note: A mount point name, as noted in fstab, needs to have an existing directory. aptosid creates these directories during the installation process under /media and they are named diskXpartX.

If you have manipulated the partition table after the initial installation and assuming you have already altered fstab, (for example, 2 new partitions have been created), the directory for each mount point will not exist and it needs to be manually created.

Example:

First, as root, confirm the existing mount points:

cd /media
ls

It should return the existing mount points, for example:

disk1part1 disk1part3 disk2part1

Staying in /media, create the mount points of the new partitions:

mkdir disk1part6
mkdir disk2part7

To test or use partitions immediately:

mount /dev/sda6 /media/disk1part6
mount /dev/sda6 /media/disk2part7

Upon a reboot of the computer the filesystems will be mounted automatically. Read:

man mount

概要: UUID, パーティションラベルとfstab

パーシステント(持続性)ブロックデバイスネーミングはudevの導入によって可能になり、バスに基づいたネーミングより有利な点がいくつかあります。

Linuxのディストロやudevが進化しハードウェア探査が信頼できるものになる一方でさまざまな問題や変更点も起こっています:
1) 複数のSATA/SCSIまたはIDEのディスクコントローラがある場合、その番号順は不規則です。 結果としてhdXやhdYといったデバイス名が起動のたびに不規則に交替することが起こります。 sdXやsdYの場合も同じです。 持続性ネーミングを使えばこの問題をまたく気にしないですみます。
2) 新しく導入されたlibataのpataサポートにより、IDEのhdXデバイスは近いうちにみなsdXになります。 この場合も持続性ネーミングを使っていればこの移行を気にせずに使えます。
3) SATAとIDEの両方のあるPCもこの頃は珍しくありません。 上記のlibataへの以降で、SATAとIDEのハードディスクがどちらもsdXの名で呼ばれるため、1)の項目の問題がより頻繁に起こるようになります。

aptosidではインストールの際、デフォルトでUUIDが使われます

他にも数々の理由がありますが、上にあげたことがもっかもっとも重要な点で、aptosidが持続性ネーミングを使うよう推奨する理由です。

4種類の持続性ネーミング:

1. UUIDによる持続性ネーミング

UUIDはUniversally Unique Identifierの略でファイルシステムの一つ一つに独自のIDを与え、IDの衝突がおこらないようデザインされています。 スワップパーティションも含め、LinuxのファイルシステムはすべてUUIDをサポートしています。 FATとNTFSファイルシステムはUUIDをサポートしませんが、by-uuidに独自のIDで表示されます:

$ /bin/ls -lF /dev/disk/by-uuid/
total 0
lrwxrwxrwx 1 root root 10 Oct 16 10:27 2d781b26-0285-421a-b9d0-d4a0d3b55680 -> ../../sda1
lrwxrwxrwx 1 root root 10 Oct 16 10:27 31f8eb0d-612b-4805-835e-0e6d8b8c5591 -> ../../sda7
lrwxrwxrwx 1 root root 10 Oct 16 10:27 3FC2-3DDB -> ../../sda6
lrwxrwxrwx 1 root root 10 Oct 16 10:27 5090093f-e023-4a93-b2b6-8a9568dd23dc -> ../../sda2
lrwxrwxrwx 1 root root 10 Oct 16 10:27 912c7844-5430-4eea-b55c-e23f8959a8ee -> ../../sda5
lrwxrwxrwx 1 root root 10 Oct 16 10:27 B0DC1977DC193954 -> ../../sdb1
lrwxrwxrwx 1 root root 10 Oct 16 10:27 bae98338-ec29-4beb-aacf-107e44599b2e -> ../../sdb2

As you can see, the fat and ntfs partitions have shorter names (sda6 and sdb1), but are still listed by uuid.

2. ラベルによる持続性ネーミング

どんなファイルシステムも大抵ラベルをつけることができます。 ラベルがついているパーティションはすべて /dev/disk/by-label ディレクトリから表示できます:

$ ls -lF /dev/disk/by-label
total 0
lrwxrwxrwx 1 root root 10 Oct 16 10:27 data -> ../../sdb2
lrwxrwxrwx 1 root root 10 Oct 16 10:27 data2 -> ../../sda2
lrwxrwxrwx 1 root root 10 Oct 16 10:27 fat -> ../../sda6
lrwxrwxrwx 1 root root 10 Oct 16 10:27 home -> ../../sda7
lrwxrwxrwx 1 root root 10 Oct 16 10:27 root -> ../../sda1
lrwxrwxrwx 1 root root 10 Oct 16 10:27 swap -> ../../sda5
lrwxrwxrwx 1 root root 10 Oct 16 10:27 windows -> ../../sdb1

While labels may have recognisable names, you need to exercise extreme caution to negate name collisions.

ファイルシステムのラベルを変更するコマンドは:

* swap: 新しいスワップスペースを作るには:  mkswap -L <label> /dev/XXX
* ext2/ext3/ext4: e2label /dev/XXX <label>
* jfs: jfs_tune -L <label> /dev/XXX
* xfs: xfs_admin -L <label> /dev/XXX
* fat/vfat: ラベルを変更するツールはLinuxにはありませんが
  ファイルシステムを作成するとき他のオプションとともに
  mkdosfs -n <label> <他のオプション> を使うことができます。
  すでに作成されているFAT/VFATのラベルはWindowsを使って変更できます。
* ntfs: ntfslabel /dev/XXX <label> またはWindowsを使って変更できます。

注意: ファイルシステムを区別するためにはラベルは一つ一つが異なっている必要があります。 これはUSB/firewireスティックやUSBドライブも含めてのことです。 UN*Xパーティションについては/dev/disk/by-*/ のシンタックスよりLABEL=/ UUID= のシンタックスのほうを使うべきです。

3. IDによる持続性ネーミング

by-id を使うとハードウェアのシリアル番号から独自のIDを作成します。

3. pathによる持続性ネーミング

by-pathを使うと(sysfsの)一番短いフィジカルパスに基づいて独自のデバイス名を作ります。 どちらもどのサブシステムに属するかを表す文字列を使うためこのページの始めに述べた問題を解決するのには向いていません。 そのためここではこれ以上触れません。

持続性ネーミングを有効にするには

どのネーミング方法を使うかを決めたら、これを実際に使うように設定しましょう:

fstabの編集

/etc/fstabで持続性ネーミングを使うのは簡単です。 最初のコラムのデバイスネームを持続性ネーミングと交換するだけです。 上の例でいえば、ただ /dev/sda7 を次のいずれかと交換します:

/dev/disk/by-label/home or
/dev/disk/by-uuid/31f8eb0d-612b-4805-835e-0e6d8b8c5591

これをfstabのすべてのパーティションについて行います。

デバイス名を書く代わりに、マウントするファイルシステムをLABEL=<label> または UUID=<uuid>, と書くことでラベル名またはUUIDで指定することもできます。 一例:

LABEL=Boot

または

UUID=3e6be9de-8139-11d1-9106-a43f08d823a6

出典: wiki.archlinux.org (ここの情報源は marc.theaimsgroup.com) wiki.archlinux.org の内容はGNU Free Documentation License 1.2 に基づいて利用され、aptosid-manualのために再編集されています

ラベリングについてのもっと詳しいことはこちらのlissot.netへ

Content last revised 26/04/2011 1355 UTC