ストレージのクラッシュ対策とバックアップ

以下のテキストは、執筆時当時の情報を元に書いたものであり、 現在の情勢にそぐわないことを含む場合があるので注意されたい。 また、テキストは最終提出原稿で校正を経る前のものなので、実際にUNIXUSER 本誌に記載されたものとは異なる。誤字脱字等そのままである。

致命的な誤り以外は加筆修正等は行なわないので情報の鮮度に気をつけつつ 利用して欲しい。

目次


===========================================
Part 2
===========================================



CPU
CPU
(HDD)




Part 2


200111


2001


	PCHDD
	(;_;)
	


 
---[ ]------------------------------------------------------------

http://www.gentei.org/~yuuji/support/uu/200110/part3.html


----------------------------------------------------------------------





HDD
IDE20
RAIDrsynccron



WindowsGUI




PC()
PCPC
 

---[ ]------------------------------------------------------------
PC1

----------------------------------------------------------------------


HDD
HDD
HDD






()
















11
 

---[ ]------------------------------------------------------------
CVSSubversion

pdumpfs (http://namazu.org/~satoru/pdumpfs/)
glastree (http://www.igmus.org/code/)

----------------------------------------------------------------------







(fstab)




HDD!



HDD

HDD

HDD




HDDHDD
HDD1
523
HDD





HDD

HDD


  (1) 
      
      ( /usr )
	# mount -r /usr
  (2) (Part2)
  (3) 2
      


(2)(3)
fsck



HDD

HDDHDD
HDD 


---[ ]------------------------------------------------------------
 %image usb-hdd1.jpg
 USB 22.5 IDE-HDD  USB 

 %image usb-hdd2.jpg
 2.5HDDPC
 211
----------------------------------------------------------------------

IDEHDDUSB

HDD

HDDUSB


 /dev/da0s1e 

dd 


	# dd if=/dev/da0s1e of=hogehoge ibs=1b \
		conv=noerror,sync

noerror sync

NULL


 

---[ ]------------------------------------------------------------
dd  obs=2M obs

----------------------------------------------------------------------

OS
FreeBSD mdconfig Linux losetup 
dd hogehoge 

	FreeBSD
	mdconfig -t vnode -a -f hogehoge -u 1
	("1")

	Linux
	losetup /dev/loop1 hogehoge
	("1")

FreeBSD /dev/md4 Linux
 /dev/loop1 fsck
mountfsck



superblock!

fsck

	Cannot find file system superblock

superblock

superblock
superblock
superblock
newfs(mke2fs)

-----------------------------------------------------
FreeBSD
# newfs /dev/md1a
/dev/md1a: 100.0MB (204784 sectors) block size 16384, fragment size 2048
        using 4 cylinder groups of 25.00MB, 1600 blks, 3200 inodes.
super-block backups (for fsck -b #) at:
 160, 51360, 102560, 153760                 

Linux
# mke2fs /dev/hdd1
mke2fs 1.35 (28-Feb-2004)
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
12768 inodes, 50872 blocks
2543 blocks (5.00%) reserved for the super user
First data block=1
7 block groups
8192 blocks per group, 8192 fragments per group
1824 inodes per group
Superblock backups stored on blocks:
        8193, 24577, 40961                  
-----------------------------------------------------

fscksuperblock1

superblocknewfs(mke2fs) -n 
-n newfs
superblocksuperblock 
fsck -b 

-----------------------------------------------------
FreeBSD
# fsck_ffs -b 123456 /dev/da0s1e

Linux
# e2fsck -b 123456 /dev/hdd1
-----------------------------------------------------



!

HDD

 fsck 

HDD
 
HDDHDD


---[ ]------------------------------------------------------------
NetBSDcron

----------------------------------------------------------------------



FreeBSDBSD 



---[ ]--------------------------------------------------------

FreeBSD
* ad0
# fdisk ad0
  ~~~~~~~~~
parameters extracted from in-core disklabel are:
cylinders=319120 heads=16 sectors/track=63 (1008 blks/cyl)

Figures below won't work with BIOS for partitions not in cyl 1
parameters to be used for BIOS calculations are:
cylinders=319120 heads=16 sectors/track=63 (1008 blks/cyl)

Media sector size is 512
Warning: BIOS sector numbering starts with sector 1
Information from DOS bootblock is:
The data for partition 1 is:             <<--- ad0s1FreeBSD
sysid 165 (0xa5),(FreeBSD/NetBSD/386BSD) <<--- 63321669432
    start 63, size 321669432 (157065 Meg), flag 80 (active)
        beg: cyl 0/ head 1/ sector 1;
        end: cyl 1023/ head 254/ sector 63
The data for partition 2 is:

The data for partition 3 is:

The data for partition 4 is:



* ad0s1BSD

# disklabel ad0s1
  ~~~~~~~~~~~~~~~
# /dev/ad0s1:
8 partitions:
#        size   offset    fstype   [fsize bsize bps/cpg]
a:  2097152        0    4.2BSD     1024  8192    22 
b:  2097152  2097152      swap                    
c: 321669432       0    unused        0     0         # "raw" part, don't edit
e:  2097152  4194304    4.2BSD     1024  8192    22 
f: 12582912  6291456    4.2BSD     1024  8192 46232 
g: 302795064 18874368    vinum                    

Linux
hda

# fdisk -l /dev/hda
  ~~~~~~~~~~~~~~~~~
Disk /dev/hda: 2516 MB, 2516484096 bytes
128 heads, 63 sectors/track, 609 cylinders
Units =  of 8064 * 512 = 4128768 bytes

                ID  
/dev/hda1   *         1        13     52384+  83  Linux
/dev/hda2            14       583   2298240   83  Linux
/dev/hda3           584       609    104832   82  Linux 
----------------------------------------------------------------------



HDDUSB
HDD

HDD


FreeBSD
HDD /dev/da0 


	# fdisk -I /dev/da0

0
1=63
=321669432

	# fdisk -1 -u /dev/da0
	  ~~~~~~~~~~~~~~~~~~~~
	Do you want to change our idea of what BIOS thinks ? [n] 
	( n )
	The data for partition 1 is:
	
	Do you want to change it? [n] y
	       	       	      	      ~
	Supply a decimal value for "sysid (165=FreeBSD)" [0] 165
							     ~~~
	Supply a decimal value for "size" [0] 321669432
	       	 	       	   	      ~~~~~~~~~
	Explicitly specify beg/end address ? [n] n
		   	   	   	     	 ~
	Are we happy with this entry? [n] y
	       	     	       	      	  ~

y
/dev/da0s1 1

disklabelBSD 
 disklabel 
 foo /dev/da0s1 


	# disklabel -w /dev/da0s1
	# disklabel -R /dev/da0s1 foo

fsck


Linux
fdiskHDD /dev/sda 
2=14=583


	# fdisk /dev/sda
	 (m ): n
		    	       ~
	
	  e   
	  p    (1-4)
	p
	~
	 (1-4): 2
		 	~
	  (1-1008,  1): 14
	     	      	       	      	  ~~
	   +  +M  +K
	 (1-1008,  1008): 583
	 	  	 	~~~
 w 

HDD

HDDHDD

HDD
HDD
HDD40GBHDD
40GB
 HDDHDD2
11

HDD

---[ ]------------------------------------------------------------

        dd
  +------+      +------+
  |      |	|      |
  | 40GB | ---->| 80GB |
  |      |      |      | 
  +-TTTT-+	+-TTTT-+   (40GB-HDD)
  HDD       HDD                  
----------------------------------------------------------------------

HDD

	dd if=/dev/zero of=/dev/sd0 bs=1b count=63  (FreeBSD)
	dd if=/dev/zero of=/dev/sda bs=1b count=63  (Linux)

fdisk(8)






HDD
HDDHDD

?


 cp 
UNIX
UNIX
 cp -r 


tar

tar

Unixtar(TapeARchiver)tar





 A B


	# tar -cf - A | tar -xpf - -C B

SSH


	# tar -cf - A | ssh remotehost tar -xpf - -C B

tar 

---[ ]------------------------------------------------------------
tar

[]
-c		
-t		
-x		

[]
-f		
		- 
-C		
		/
-p		
-z		()gzip
		()
--one-file-system
		
		
		
----------------------------------------------------------------------


ACL

 POSIX ACL(Access Control List)
ACL

tar(1)dump(8)ACL


----------[ 1 POSIX ACL ]---------------------------------------

POSIX ACLUNIX
3

	
	
	

ACL
 foo 

	taro  hanako 

setfcl(1)

	% setfacl -m u:taro:r--,u:hanako:r--,g:---,o:--- foo

ACLgetfcl(1)

	% getfcl foo
	  ~~~~~~~~~~
	# file: foo
	# owner: yuuji
	# group: staff
	user::rw-
	user:taro:r--                #effective:r--
	user:hanako:r-                #effective:rw-
	group::---              #effective:---
	mask:r--
	other:---

FreeBSD5ACL
 acls  /etc/fstab 

	/dev/ad0s1e	/usr	ufs	rw	2	2

ACL

	/dev/ad0s1e	/usr	ufs	rw,acls	2	2

Linux  acl (
)
----------------------------------------------------------------------

star

ACLstar

http://cdrecord.berlios.de/old/private/star.html

starcdrecord Joerg Schilling 
ftp://ftp.berlios.de/pub/star/alpha/ 

	star-1.5a60.tar.bz2
	MD5 (star-1.5a60.tar.bz2) = 6f48614d05a4f91ba024f7b7691236c9

smakeGNU make


	% gtar jxpf star-1.5a60.tar.bz2
	% cd star-1.5a60
	% gmake


	./star/OBJ/-cc/

 star_fat 

	# gmake install

 /opt/schily/ 
 ./DEFAULTS/Defaults. 
INS_BASE 

starACL

starGNU tar 
11
star(1)A
BACLACL
-acl 

	# star -c -Hexustar -acl -C A . | star -xp -acl -C B

-H 
exustarACL

rsync

rsync 
rsync



	# rsync -aH --delete A B

ABA
B

	/home/yuuji  /backup/home/yuuji 



	# rsync -aH /home/yuuji /backup/home

 n 


	# rsync -aHn /home/yuuji /backup/home


: 

	# rsync -aH A remotehost:B

B
ssh
 rootssh
 2


---[ ]------------------------------------------------------------
http://rsync.samba.org
----------------------------------------------------------------------

---[ ]------------------------------------------------------------
rsync 2.6.0 ssh
----------------------------------------------------------------------

----------[ 2 rootSSH ]-------------------------


rootSSH
rootSSH


* 
* root ~/.ssh 
* 
* 

(SSH)rootSSH
/etc/ssh/sshd_config  PermitRootLogin 


PermitRootLogin without-password

sshdHUP

# kill -1 `cat /var/run/sshd.pid`

 Host-A(10.1.1.1)  Host-B SSH


* 
*  ~/.ssh/authorized_keys 



Host-A# ssh-keygen -t dsa -f ~/.ssh/backup
Generating public/private dsa key pair.
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 

cron
(.ssh/backup.pub)Host-B


Host-B ~/.ssh/authorized_keys 

Host-B# touch $HOME/.ssh/authorized_keys
Host-B# chmod og-r $HOME/.ssh/authorized_keys
Host-B# vi $HOME/.ssh/authorized_keys
       backup.pub
       kterm
       (vi G:r backup.pub)

(1)

	from="10.1.1.1",no-pty,no-port-forwarding ssh-dss AAAA....
	~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Host-A(10.1.1.1)


Host-A.ssh/backup

Host-A# env - PATH="$PATH" sh	(PATHsh)
Host-A# ssh -i $HOME/.ssh/backup Host-B hostname
	Host-Bhostname
	sh


 Host-A  /home  Host-B 
/backup/Host-A 

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#!/bin/sh
unset SSH_AUTH_SOCK
RSYNC_RSH="ssh -i $HOME/.ssh/backup"; export RSYNC_RSH
rsync -avH --delete /home Host-B:/backup/Host-A
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -


----------------------------------------------------------------------



---[ ]------------------------------------------------------------
----------------------------------------------------------------------
---[ ]------------------------------------------------------------
----------------------------------------------------------------------
---[ ]------------------------------------------------------------
----------------------------------------------------------------------
---[ ]------------------------------------------------------------
----------------------------------------------------------------------


yuuji@gentei.org
Fingerprint16 = FF F9 FF CC E0 FE 5C F7 19 97 28 24 EC 5D 39 BA
HIROSE Yuuji - ASTROLOGY / BIKE / EPO / GUEST BOOK / YaTeX [Tweet]