adduser 유저이름


으로 추가하면 된다.

이름, 전화번호 이런걸 물어보는데, 적당히 적어주고 마지막에 입력한 정보가 맞냐고 할 때 Y를 눌러주고 나오면 된다.

잘 만들어졌는지 확인하기 위해, /home/유저이름 으로 된 디렉터리가 생겼는지 확인해 보면 된다.

Posted by code cat
리눅스/커널2012. 2. 23. 00:43

출처: http://www.ibm.com/developerworks/linux/library/l-gcc-hacks/


GCC 확장(?)의 하나로서, GCC는 변수에 대한 참조를 통해서 타입을 확인할 수 있다. 이런 방법을 흔히 'generic programming'이라고 부르며 비슷한 기능을 제공하는 것을 현재 쓰이는 언어들에서 찾아 볼 수 있다.[1]
Linux의 경우, typeof를 사용하여 타입 종속적인 작업, (예를 들어 min/max 를 구별)을 할 수 있다.

간단한 예를 들어보자.(/linux/include/linux/kernel.h)

보이는 바와 같이 _min1은 x가 어떤 타입이냐에 따라서 그 타입을 가지게 된다; _min2 역시 y에 따라 타입이 달라진다. 이렇게 타입을 가지게 되므로 크기를 비교할 수 있게 되며, 어떠한 타입이 들어와도 대응할 수 있게 된다.

[1] 제네릭 프로그래밍(Generic programming)은 데이터 형식에 의존하지 않고, 하나의 값이 여러 다른 데이터 타입들을 가질 수 있는 기술에 중점을 두어 재사용성을 높일 수 있는 프로그래밍 방식이다

'리눅스 > 커널' 카테고리의 다른 글

리눅스 커널 분석 시 아키텍쳐별 tag 및 cscope생성  (0) 2012.04.16
Virtual Linux Manager 정리 1  (0) 2012.03.18
Documentation/arm/booting  (0) 2011.09.25
Linux 3.0 Kernel  (0) 2011.07.31
커널선점  (0) 2011.05.01
Posted by code cat
리눅스2012. 1. 3. 08:59

(출처: Beginning Linux Programming 3rd edition)


알면서도 안 써먹는 거 같아서... 써 놓으면 생각날때 써먹을 수 있을거 같아서 쓴다.

umask는 open 혹은 create 호출을 통하여 파일을 만들 때 mode 매개변수를 umask와 비교한다.

mode 매개변수와 umask에 공통으로 설정되어 있는 비트는 제거된다.  결국 사용자는 "파일을 만드는 프로그램이 다른 사용자의 쓰기 권한을 요청하더라도 이 권한을 가지고 있는 어떤 파일도  만들면 안된다"라고 이야기하는 환경을 설정할 수 있다.


비록 그렇다고 해도 사용자나 프로그램이 chmod 명령을 연속으로 사용하여 다른 사용자의 쓰기 권한을 추가하는 것까지 방지할 수는 없다.  그렇지만 새로 생성하는 모든 파일에 대해 권한을 검사하고 설정하는 노력을 사용자로부터 덜어줄 수는 있다.


Posted by code cat
리눅스/커널2011. 9. 25. 14:47
1 Booting ARM Linux
2 =================
3
4 Author: Russell King
5 Date : 18 May 2002
6
7 The following documentation is relevant to 2.4.18-rmk6 and beyond.
8
9 In order to boot ARM Linux, you require a boot loader, which is a small
10 program that runs before the main kernel. The boot loader is expected
11 to initialise various devices, and eventually call the Linux kernel,
12 passing information to the kernel.
13
14 Essentially, the boot loader should provide (as a minimum) the
15 following:
16
17 1. Setup and initialise the RAM.
18 2. Initialise one serial port.
19 3. Detect the machine type.
20 4. Setup the kernel tagged list.
21 5. Call the kernel image.
22
23
24 1. Setup and initialise RAM
25 ---------------------------
26
27 Existing boot loaders: MANDATORY
28 New boot loaders: MANDATORY
29
30 The boot loader is expected to find and initialise all RAM that the
31 kernel will use for volatile data storage in the system. It performs
32 this in a machine dependent manner. (It may use internal algorithms
33 to automatically locate and size all RAM, or it may use knowledge of
34 the RAM in the machine, or any other method the boot loader designer
35 sees fit.)
36
37
38 2. Initialise one serial port
39 -----------------------------
40
41 Existing boot loaders: OPTIONAL, RECOMMENDED
42 New boot loaders: OPTIONAL, RECOMMENDED
43
44 The boot loader should initialise and enable one serial port on the
45 target. This allows the kernel serial driver to automatically detect
46 which serial port it should use for the kernel console (generally
47 used for debugging purposes, or communication with the target.)
48
49 As an alternative, the boot loader can pass the relevant 'console='
50 option to the kernel via the tagged lists specifying the port, and
51 serial format options as described in
52
53 Documentation/kernel-parameters.txt.
54
55
56 3. Detect the machine type
57 --------------------------
58
59 Existing boot loaders: OPTIONAL
60 New boot loaders: MANDATORY
61
62 The boot loader should detect the machine type its running on by some
63 method. Whether this is a hard coded value or some algorithm that
64 looks at the connected hardware is beyond the scope of this document.
65 The boot loader must ultimately be able to provide a MACH_TYPE_xxx
66 value to the kernel. (see linux/arch/arm/tools/mach-types).
67
68
69 4. Setup the kernel tagged list
70 -------------------------------
71
72 Existing boot loaders: OPTIONAL, HIGHLY RECOMMENDED
73 New boot loaders: MANDATORY
74
75 The boot loader must create and initialise the kernel tagged list.
76 A valid tagged list starts with ATAG_CORE and ends with ATAG_NONE.
77 The ATAG_CORE tag may or may not be empty. An empty ATAG_CORE tag
78 has the size field set to '2' (0x00000002). The ATAG_NONE must set
79 the size field to zero.
80
81 Any number of tags can be placed in the list. It is undefined
82 whether a repeated tag appends to the information carried by the
83 previous tag, or whether it replaces the information in its
84 entirety; some tags behave as the former, others the latter.
85
86 The boot loader must pass at a minimum the size and location of
87 the system memory, and root filesystem location. Therefore, the
88 minimum tagged list should look:
89
90 +-----------+
91 base -> | ATAG_CORE | |
92 +-----------+ |
93 | ATAG_MEM | | increasing address
94 +-----------+ |
95 | ATAG_NONE | |
96 +-----------+ v
97
98 The tagged list should be stored in system RAM.
99
100 The tagged list must be placed in a region of memory where neither
101 the kernel decompressor nor initrd 'bootp' program will overwrite
102 it. The recommended placement is in the first 16KiB of RAM.
103
104 5. Calling the kernel image
105 ---------------------------
106
107 Existing boot loaders: MANDATORY
108 New boot loaders: MANDATORY
109
110 There are two options for calling the kernel zImage. If the zImage
111 is stored in flash, and is linked correctly to be run from flash,
112 then it is legal for the boot loader to call the zImage in flash
113 directly.
114
115 The zImage may also be placed in system RAM (at any location) and
116 called there. Note that the kernel uses 16K of RAM below the image
117 to store page tables. The recommended placement is 32KiB into RAM.
118
119 In either case, the following conditions must be met:
120
121 - Quiesce all DMA capable devices so that memory does not get
122 corrupted by bogus network packets or disk data. This will save
123 you many hours of debug.
124
125 - CPU register settings
126 r0 = 0,
127 r1 = machine type number discovered in (3) above.
128 r2 = physical address of tagged list in system RAM.
129
130 - CPU mode
131 All forms of interrupts must be disabled (IRQs and FIQs)
132 The CPU must be in SVC mode. (A special exception exists for Angel)
133
134 - Caches, MMUs
135 The MMU must be off.
136 Instruction cache may be on or off.
137 Data cache must be off.
138
139 - The boot loader is expected to call the kernel image by jumping
140 directly to the first instruction of the kernel image.

'리눅스 > 커널' 카테고리의 다른 글

Virtual Linux Manager 정리 1  (0) 2012.03.18
GCC, typeof  (0) 2012.02.23
Linux 3.0 Kernel  (0) 2011.07.31
커널선점  (0) 2011.05.01
커널 스레드  (0) 2011.05.01
Posted by code cat
시스템 시간이 다른 머신 사이에서 tar로 압축해서 파일을 옮길때,
tar: 파일 어쩌구저쩌구.c  time stamp 날짜 시간 s in the future 이런 식으로 메세지가 뜨면은

파일을 풀 때, m 옵션을 넣어주면 된다.  man tar를 보면, m옵션에 대해서 다음과 같이 기재되어 있다.

-m, --touch, --modification-time 
don't extract file modified time

 

즉 변환된 시간을 넣지 말라는 소리다.

그러므로,
tar xvfz archive.tar.gz

대신
tar xmvfz archive.tar.gz

하면 된다. 


Posted by code cat
리눅스2011. 8. 17. 14:21
출처: http://www.novell.com/support/search.do?cmd=displayKC&sliceId=SAL_Public&externalId=3907838
 

JBD: barrier-based sync failed on mmcblkxxx -diabling barriers

JBD = 저널링 블록 디바이스
이 메세지를 끌라면, barrier=off 라는 매게변수를 커널에 넘겨주면 된다. GRUB의 경우에는 /boot/grub/menu.lst에 넣으면 되겠다.  이렇게 하면 커널은 transaction barrier 메카니즘을 사용하지 않게된다.

기본적으로 리눅스 커널은 transaction barrier를 사용하는데, 이는 데이터의 보전성을 유지하기 위한 부가적인 메카니즘이다.
많은 저장 서브시스템은 data의 write 퍼포먼스를 높이기 위해 캐시나 쓰는 order를 변경하는데, 이는 저널링 파일 시스템안에서 관리되는 저널된 데이터에겐 좋지 않다.  저널링은 실제 데이터가 쓰여지기 전에 메타데이터를 씀으로서 크래시 리커버리를 구현한다.  위의 에러(?) 메세지는 그러한 transaction barrier를 지원하지 않는다는 소리이며, 전혀 해로울것은 없지만, barrier는 일반적으로 퍼포먼스를 높여준다.

Posted by code cat
리눅스2011. 8. 2. 20:39
dd if=/dev/zero of=ext4.img bs=1MB count=20  // 20mb 짜리 ext4.img라는 파일을 생성

mke2fs -T ext4 ext4.img  //ext4 타입으로 ext4.img를 포맷


mkdir test //테스트용 디렉토리 생성(마운트 포인트로 이용)

mount -t ext4 -o loop ext4.img test/   //마운트

마운트가 성공됬으면(mount 커맨드로 확인), 테스트로 파일을 막 써보자.
cd test
touch TEMPFILE
mkdir BABO
...

파일이 제대로 생성됐는지 확인해보고, 언마운트를 해보자
cd ..  //test 폴더 안에서 언마운트 할라면 device busy라고 불평한다.
umount /dev/loop0  //꼭 loop0이라는 보장은 없고 아마 마운트시 available한 loop이 잡히는 걸로 안다.
                             //이 부분은 losetup으로 체크할 수 있는 걸로 안다.
cd test/
ls -al 로 확인하면 텅 빈 걸 확인할 수 있다.

다시 마운트 해보자.
mount -t ext4 -o loop ext4.img test/ 
ls -al
해보면 아까 테스트로 막 만든 파일들이 보인다.

자 그럼 이걸 가지고 뭐에 써먹냐 ?  ext4.img 자체를 파티션에 그대로 구울 경우, ext4파일 시스템을 가진 루트파일 시스템 등을 구축 할 수 있는 것이다.  EXT4f라고 썼지만 다른 파일 시스템도 이렇게 해서 굽는게 가능하다.  물론 안드로이드용 파일 시스템을 만들 땐 이걸 안 썼다. 언제 저 짓해서 맨날 구워줄 수 있단 말인가?  다른 방법에 대해서는 다음 기회에~
Posted by code cat

dd if=/dev/zero of=ext3.image bs=1MB count=1024

포맷에 따라서 파일을 복사하거나 변환시킴(주로 빈 파일 만들거나, loopback 디바이스 만들 때 사이즈 할당 시켜서 파일 만들 때 씀)

if=FILE
표준 입력 대신 파일로부터 읽어들인 파일
of=FILE
표준아웃으로 대신 파일로 씀
bs=BYTES
          ibs랑 obs를 BYTES로 강제 설정
count=BLOCKS
BLOCKS 만큼의 입력 블록을 복사함.

더 많은 정보는 http://linux.die.net/man/1/dd

 

'리눅스 > 스크립트/유틸' 카테고리의 다른 글

우분투 사용자 추가  (0) 2012.02.24
tar: time stamp s in the future  (0) 2011.08.26
tee 커맨드  (0) 2011.06.19
엔디안 처리하는 함수  (0) 2011.06.06
busybox cross-compile  (0) 2011.06.01
Posted by code cat
리눅스/커널2011. 7. 31. 15:07

툴체인 설치 하고 커널 컴파일 준비 끝!

'리눅스 > 커널' 카테고리의 다른 글

GCC, typeof  (0) 2012.02.23
Documentation/arm/booting  (0) 2011.09.25
커널선점  (0) 2011.05.01
커널 스레드  (0) 2011.05.01
커널 초기화  (0) 2011.04.20
Posted by code cat
리눅스2011. 6. 27. 17:25

VMware에서 리눅스를 깐 경우, 가끔 컴퓨터 크래쉬로 인해 리눅스로 resume이 안될 때가 있다.(오늘 내가 그랬다. T_T)
 
이럴땐, 우선 vmware에서 추천하는데로 chkdsk로 파일 불량섹터를 검사해보고, (링크 참조)

http://kb.vmware.com/selfservice/microsites/search.do?cmd=displayKC&docType=kc&externalId=1004003&sliceId=1&docTypeID=DT_KB_1_1&dialogID=13876493&stateId=1%200%2013880251

이래도 안되면 virtual machine이 있는 디렉토리(보통 다큐먼트 쪽 폴더에 있다. my virtual machine 디렉토리를 체크하길 바란다.)에서 .vmem이라는 파일이 있을 것이다.  이 파일을 지우면, 비록 suspended 된 시점으로 resume은 안되지만, 처음부터(power-on한거처럼) 작동 할 것이다.

문제해결!
 

'리눅스' 카테고리의 다른 글

Linux: umask  (0) 2012.01.03
JBD error message "barrier-based sync failed"  (0) 2011.08.17
EXT4 파일 시스템 굽기  (0) 2011.08.02
[Ubuntu] Ubuntu 에서 make menuconfig 안될때,  (0) 2011.04.22
/opt, 리눅스 패키지 설치  (0) 2011.04.20
Posted by code cat