리눅스 부팅시 스크립트 자동시작 등록
1. 개요
가. 리눅스 서버 부팅시 자동으로 시작해야하는 스크립트(또는 프로그램)가 있다면
다음과 같이 파일에 등록하면 됩니다.
나. 테스트환경 : CentOS 5.1
2. 리눅스 부팅시 스크립트 자동시작 등록
/etc/rc.d/rc.local 파일에 스크립트(예 /etc/script/report.sh) 등록
[root@ruo91 ~]# fdisk -l/dev/sdb 가 새로 추가한 하드디스크로 인식이 되었으므로 새로운 파티션을 추가 해줍니다.
Disk /dev/sda: 536.8 GB, 536870912000 bytes
255 heads, 63 sectors/track, 65270 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 65140 523237018+ 83 Linux
/dev/sda2 65141 65270 1044225 82 Linux swap / Solaris
Disk /dev/sdb: 536.8 GB, 536870912000 bytes
255 heads, 63 sectors/track, 65270 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
[root@ruo91 ~]# fdisk /dev/sdb
The number of cylinders for this disk is set to 65270.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-65270, default 1): 1
Last cylinder or +size or +sizeM or +sizeK (1-65270, default 65270): 65270
Command (m for help): p
Disk /dev/sdb: 536.8 GB, 536870912000 bytes
255 heads, 63 sectors/track, 65270 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 1 65270 524281243+ 83 Linux
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
a - 부트 가능한 플래그로 변경
b - bsd 디스크 레이블을 편집
c - 도스 호환 플래그로 변경
d - 파티션 삭제
l - 리눅스에서 지원하는 파티션 목록보기
m - 메뉴보기
n - 새로운 파티션 생성
o - 새로운 도스 파티션 테이블 생성
p - 현재 파티션 설정 상태 확인
q - 설정한 파티션 저장하지 않고 종료
s - 새로운 Sun 디스크 레이블 생성
t - 파티션 시스템 유형 변경
u - 표시/항목 단위를 변경
v - 파티션 레이블 점검
w - 설정한 파티션을 저장하고 종료
x - 고급 사용자를 위한 명령어
[root@ruo91 ~]# fdisk -l
Disk /dev/sda: 536.8 GB, 536870912000 bytes
255 heads, 63 sectors/track, 65270 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 65140 523237018+ 83 Linux
/dev/sda2 65141 65270 1044225 82 Linux swap / Solaris
Disk /dev/sdb: 536.8 GB, 536870912000 bytes
255 heads, 63 sectors/track, 65270 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 1 65270 524281243+ 83 Linux
[root@ruo91 ~]# mkfs -t ext3 /dev/sdb
mke2fs 1.39 (29-May-2006)
/dev/sdb is entire device, not just one partition!
Proceed anyway? (y,n) y
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
65536000 inodes, 131072000 blocks
6553600 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=0
4000 block groups
32768 blocks per group, 32768 fragments per group
16384 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
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 23 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
[root@ruo91 ~]# mkdir /home2
[root@ruo91 ~]# mount /dev/sdb /home2
[root@ruo91 ~]# mount
/dev/sda1 on / type ext3 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
tmpfs on /dev/shm type tmpfs (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
/dev/sdb on /home2 type ext3 (rw)
[root@ruo91 ~]# cat > /home2/hello.cpp
#include <iostream>
int main()
{
std::cout<< "Hello World!!" <<std::endl;
return 0;
}
[root@ruo91 ~]# g++ -o /home2/hello /home2/hello.cpp
[root@ruo91 ~]# /home2/hello
Hello World!!
[root@ruo91 ~]# vim /etc/fstab
/dev/sdb /home2 ext3 defaults 0 0
[root@ruo91 ~]# reboot
[root@ruo91 ~]# mount자료출처 : http://www.cyworld.com/ruo91/3368109
/dev/sda1 on / type ext3 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
tmpfs on /dev/shm type tmpfs (rw)
/dev/sdb on /home2 type ext3 (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)