導航:首頁 > 源碼編譯 > 編譯內核空間

編譯內核空間

發布時間:2023-08-12 07:45:07

『壹』 每個編譯器都不一樣么 c語言一般用什麼編譯器 每次一種編譯器不能編譯 另一種卻能編譯出

編譯器就是c語言編譯成二進制的東西,
不同的編譯器是不同的,
比如16位系統和32位系統的編譯器就不同,因為16位的認為int是2位元組,32位的則認為是4個位元組。
另外
linux上的編譯器跟windows下的編譯器也不同,linux上的認為內核空間佔1G,而windows下則認為佔2G,
此外兩個系統對環境變數以及其他的設置也不同所以編譯器更不能用。
而且不同的CPU的指令集時不同的,所以同樣int
a
=1
最後被編譯成的二進制代碼也是不同的。
C語言的編譯器有很多,windows下的編譯器也有很多,不同的編譯器可能會做一些不同的優化,linux下的gcc也可以添加選項讓他編譯windows下運行的程序。
main(int
argc,char*argv[


argc
是你的參數個數
argv是你的參數。
比如你最終程序叫
add
那麼
你在命令行執行add
1
2
那麼argc
=3
第一個參數使你的add,
第二個第三個就是
1
2,
在函數內部你就可以獲取這倆參數進行相加然後列印
visual
是個IDE,集成開發環境,已經集成好了windows下使用的編譯器連接器
等,
編寫代碼完成後直接點擊編譯就行了。
IDE的默認編譯器是可以更改的,不同的IDE設置不同。

『貳』 Linux 內核編譯時出現 「設備上沒有空間」,該如何進行重新定義空間

1)你編譯的分區空間不足了,你換一個容量大的分區進行編譯即可。
可以用df -h 查看各掛載分區的容量

2)分區用fdisk命令進行
具體可以參考《鳥哥的Linux私房菜_基礎學習篇_第三版》

『叄』 linux 編譯內核 空間不夠怎麼辦我分給linux的盤只有8G

8g按理夠了,如果不行,可以卸載一些不用軟體,也可以動態載入內核。

如果你是學習linux內核,建議不要覆蓋內核,這樣新的不行還可以用舊的,如果是單純的使用,可以覆蓋。

『肆』 ubuntu 內核編譯時文件系統空間不足怎麼辦啊,具體如何操作

編譯內核又用不了多少空間,空間不足就清理出空間來不就得了,刪掉大概2G東西夠暫時用的

如果你用得是虛擬機,擴展硬碟容量就行了,或者增加一個硬碟掛載上去,在新增加得空間里執行編譯就行了

『伍』 Ubuntu編譯了新的內核,進入新內核時一直顯示載入Linux 5.6.7,載入初始化內存檔咋回事

概述====1)當內核配置了內存檔時, 內核在初始化時可以將軟盤載入到內存檔中作為根盤.當同時配置了初始化內存檔(Initail RAM Disk)時, 內核在初始化時可以在安裝主盤之前,通過引導程序所載入的initrd文件建立一個內存初始化盤, 首先將它安裝成根文件系統, 然後執行其根目錄下的linuxrc 文件,可用於在安裝主盤之前載入一些內核模塊. 等到linuxrc 程序退出後, 再將主盤安裝成根文件系統,並將內存初始化盤轉移安裝到其/initrd目錄下.2)當主盤就是initrd所生成的內存初始化盤時, 不再進行重新安裝,在DOS下用loadlin載入的搶救盤就是這種工作方式.3)引導程序所載入的initrd為文件系統的映象文件, 可以是gzip壓縮的, 也可以是不壓縮的.能夠識別的文件系統有minix,ext2,romfs三種.4)當內核的根盤為軟盤時,內核初始化時會測試軟盤的指定部位是否存在文件系統或壓縮文件映象, 然後將之載入或解壓到內存檔中作為根盤. 這是單張搶救軟盤的工作方式.有關代碼========; init/main.c#ifdef CONFIG_BLK_DEV_INITRDkdev_t real_root_dev; 啟動參數所設定的根盤設備#endifasmlinkage void __init start_kernel(void){ char * command_line; unsigned long mempages; extern char saved_command_line[]; lock_kernel(); printk(linux_banner); setup_arch(&command_line);arch/i386/kernel/setup.c中,初始化initrd_start和initrd_end兩個變數 ...#ifdef CONFIG_BLK_DEV_INITRD if (initrd_start && !initrd_below_start_ok && initrd_start < min_low_pfn << PAGE_SHIFT) { ; min_low_pfn為內核末端_end所開始的物理頁號,initrd_start,initrd_end在rd.c中定義 printk(KERN_CRIT "initrd overwritten (0x%08lx < 0x%08lx) - " "disabling it./n",initrd_start,min_low_pfn << PAGE_SHIFT); initrd_start = 0; }#endif ... kernel_thread(init, NULL, CLONE_FS | CLONE_FILES | CLONE_SIGNAL); 創建init進程 unlock_kernel(); current->need_resched = 1; cpu_idle();}static int init(void * unused){ lock_kernel(); do_basic_setup(); /* * Ok, we have completed the initial bootup, and * we're essentially up and running. Get rid of the * initmem segments and start the user-mode stuff.. */ free_initmem(); unlock_kernel(); if (open("/dev/console", O_RDWR, 0) < 0) printk("Warning: unable to open an initial console./n"); (void) p(0); (void) p(0); /* * We try each of these until one succeeds. * * The Bourne shell can be used instead of init if we are * trying to recover a really broken machine. */ if (execute_command) execve(execute_command,argv_init,envp_init); execve("/sbin/init",argv_init,envp_init); execve("/etc/init",argv_init,envp_init); execve("/bin/init",argv_init,envp_init); execve("/bin/sh",argv_init,envp_init); panic("No init found. Try passing init= option to kernel.");}static void __init do_basic_setup(void){#ifdef CONFIG_BLK_DEV_INITRD int real_root_mountflags;#endif ...#ifdef CONFIG_BLK_DEV_INITRD real_root_dev = ROOT_DEV; ROOT_DEV為所請求根文件系統的塊設備 real_root_mountflags = root_mountflags; if (initrd_start && mount_initrd) root_mountflags &= ~MS_RDONLY; else mount_initrd =0; #endif start_context_thread(); do_initcalls(); 會調用partition_setup()中載入內存檔 /* .. filesystems .. */ filesystem_setup(); /* Mount the root filesystem.. */ mount_root(); mount_devfs_fs ();#ifdef CONFIG_BLK_DEV_INITRD root_mountflags = real_root_mountflags; if (mount_initrd && ROOT_DEV != real_root_dev && MAJOR(ROOT_DEV) == RAMDISK_MAJOR && MINOR(ROOT_DEV) == 0) { ; 如果當前根盤為initrd所建立的內存檔 int error; int i, pid; pid = kernel_thread(do_linuxrc, "/linuxrc", SIGCHLD); 創建新的任務去執行程序/linuxrc if (pid>0) while (pid != wait(&i)); 等待linuxrc進程退出 if (MAJOR(real_root_dev) != RAMDISK_MAJOR || MINOR(real_root_dev) != 0) { ; 如果原來的根盤不是0號內存檔,則使用原來的根文件系統, ; 並且將內存檔轉移到其/initrd目錄下 error = change_root(real_root_dev,"/initrd"); if (error) printk(KERN_ERR "Change root to /initrd: " "error %d/n",error); } }#endif}#ifdef CONFIG_BLK_DEV_INITRDstatic int do_linuxrc(void * shell){ static char *argv[] = { "linuxrc", NULL, }; close(0);close(1);close(2); setsid(); 設置新的session號 (void) open("/dev/console",O_RDWR,0); (void) p(0); (void) p(0); return execve(shell, argv, envp_init);}#endif; arch/i386/kernel/setup.c#define RAMDISK_IMAGE_START_MASK 0x07FF#define RAMDISK_PROMPT_FLAG 0x8000#define RAMDISK_LOAD_FLAG 0x4000 #define PARAM ((unsigned char *)empty_zero_page)#define RAMDISK_FLAGS (*(unsigned short *) (PARAM+0x1F8)) 可用rdev設置的參數#define LOADER_TYPE (*(unsigned char *) (PARAM+0x210))#define INITRD_START (*(unsigned long *) (PARAM+0x218)) 初始化盤映象起始物理地址#define INITRD_SIZE (*(unsigned long *) (PARAM+0x21c)) 初始化盤位元組數void __init setup_arch(char **cmdline_p){ ...#ifdef CONFIG_BLK_DEV_RAM rd_image_start = RAMDISK_FLAGS & RAMDISK_IMAGE_START_MASK; 以塊為單位 rd_prompt = ((RAMDISK_FLAGS & RAMDISK_PROMPT_FLAG) != 0); rd_doload = ((RAMDISK_FLAGS & RAMDISK_LOAD_FLAG) != 0);#endif ...#ifdef CONFIG_BLK_DEV_INITRD if (LOADER_TYPE && INITRD_START) { if (INITRD_START + INITRD_SIZE <= (max_low_pfn << PAGE_SHIFT)) { ; max_low_pfn表示內核空間1G范圍以下最大允許的物理頁號 reserve_bootmem(INITRD_START, INITRD_SIZE); initrd_start = INITRD_START ? INITRD_START + PAGE_OFFSET : 0; 轉變為內核邏輯地址 initrd_end = initrd_start+INITRD_SIZE; } else { printk("initrd extends beyond end of memory " "(0x%08lx > 0x%08lx)/ndisabling initrd/n", INITRD_START + INITRD_SIZE, max_low_pfn << PAGE_SHIFT); initrd_start = 0; } }#endif ...}; fs/partitions/check.c:int __init partition_setup(void){ device_init(); 包含ramdisk設備的初始化#ifdef CONFIG_BLK_DEV_RAM#ifdef CONFIG_BLK_DEV_INITRD if (initrd_start && mount_initrd) initrd_load(); ;如果啟動時載入了initrd文件,則用它去初始化根內存檔 else#endif rd_load(); 如果內核配置了內存檔並且根盤指定為軟盤則試圖將軟盤載入為根內存檔#endif return 0;}__initcall(partition_setup);; drivers/block/rd.c:int rd_doload; /* 1 = load RAM disk, 0 = don't load */int rd_prompt = 1; /* 1 = prompt for RAM disk, 0 = don't prompt */int rd_image_start; /* starting block # of image */#ifdef CONFIG_BLK_DEV_INITRDunsigned long initrd_start, initrd_end;int mount_initrd = 1; /* zero if initrd should not be mounted */int initrd_below_start_ok;void __init rd_load(void){ rd_load_disk(0); 載入到0號內存檔}void __init rd_load_secondary(void){ rd_load_disk(1); 載入到1號內存檔}static void __init rd_load_disk(int n){#ifdef CONFIG_BLK_DEV_INITRD extern kdev_t real_root_dev;#endif if (rd_doload == 0) return; if (MAJOR(ROOT_DEV) != FLOPPY_MAJOR 如果根盤是不軟盤#ifdef CONFIG_BLK_DEV_INITRD && MAJOR(real_root_dev) != FLOPPY_MAJOR#endif ) return; if (rd_prompt) {#ifdef CONFIG_BLK_DEV_FD floppy_eject();#endif#ifdef CONFIG_MAC_FLOPPY if(MAJOR(ROOT_DEV) == FLOPPY_MAJOR) swim3_fd_eject(MINOR(ROOT_DEV)); else if(MAJOR(real_root_dev) == FLOPPY_MAJOR) swim3_fd_eject(MINOR(real_root_dev));#endif printk(KERN_NOTICE "VFS: Insert root floppy disk to be loaded into RAM disk and press ENTER/n"); wait_for_keypress(); } rd_load_image(ROOT_DEV,rd_image_start, n); 將根軟盤載入到n號內存檔}void __init initrd_load(void){ ; 使用initrd設備盤作為源盤去建立內存根盤 rd_load_image(MKDEV(MAJOR_NR, INITRD_MINOR),rd_image_start,0);}static void __init rd_load_image(kdev_t device, int offset, int unit){ struct inode *inode, *out_inode; struct file infile, outfile; struct dentry in_dentry, out_dentry; mm_segment_t fs; kdev_t ram_device; int nblocks, i; char *buf; unsigned short rotate = 0; unsigned short devblocks = 0; char rotator[4] = { '|' , '/' , '-' , '//' }; ram_device = MKDEV(MAJOR_NR, unit); 建立輸出內存檔設備號 if ((inode = get_empty_inode()) == NULL) return; memset(&infile, 0, sizeof(infile)); memset(&in_dentry, 0, sizeof(in_dentry)); infile.f_mode = 1; /* read only */ infile.f_dentry = &in_dentry; in_dentry.d_inode = inode; infile.f_op = &def_blk_fops; init_special_inode(inode, S_IFBLK | S_IRUSR, kdev_t_to_nr(device)); if ((out_inode = get_empty_inode()) == NULL) goto free_inode; memset(&outfile, 0, sizeof(outfile)); memset(&out_dentry, 0, sizeof(out_dentry)); outfile.f_mode = 3; /* read/write */ outfile.f_dentry = &out_dentry; out_dentry.d_inode = out_inode; outfile.f_op = &def_blk_fops; init_special_inode(out_inode, S_IFBLK | S_IRUSR | S_IWUSR, kdev_t_to_nr(ram_device)); if (blkdev_open(inode, &infile) != 0) 打開輸入盤文件 goto free_inode; if (blkdev_open(out_inode, &outfile) != 0) 打開輸出內存檔文件 goto free_inodes; fs = get_fs(); set_fs(KERNEL_DS); nblocks = identify_ramdisk_image(device, &infile, offset); 鑒定輸入盤的文件類型 if (nblocks < 0) 出錯 goto done; if (nblocks == 0) { 表示輸入盤是gzip文件#ifdef BUILD_CRAMDISK if (crd_load(&infile, &outfile) == 0) 將輸入盤文件解壓到輸出盤文件中去 goto successful_load;#else printk(KERN_NOTICE "RAMDISK: Kernel does not support compressed " "RAM disk images/n");#endif goto done; } /* * NOTE NOTE: nblocks suppose that the blocksize is BLOCK_SIZE, so * rd_load_image will work only with filesystem BLOCK_SIZE wide! * So make sure to use 1k blocksize while generating ext2fs * ramdisk-images. */ if (nblocks > (rd_length[unit] >> BLOCK_SIZE_BITS)) { ; 如果輸入盤的尺寸超過了輸出內存檔的允許尺寸 printk("RAMDISK: image too big! (%d/%ld blocks)/n", nblocks, rd_length[unit] >> BLOCK_SIZE_BITS); goto done; } /* * OK, time to in the data */ buf = kmalloc(BLOCK_SIZE, GFP_KERNEL); if (buf == 0) { printk(KERN_ERR "RAMDISK: could not allocate buffer/n"); goto done; } if (blk_size[MAJOR(device)]) devblocks = blk_size[MAJOR(device)][MINOR(device)]; 取輸入盤的容量#ifdef CONFIG_BLK_DEV_INITRD if (MAJOR(device) == MAJOR_NR && MINOR(device) == INITRD_MINOR) devblocks = nblocks; 如果輸入是初始化內存檔,則盤的容量為它的實際尺寸#endif if (devblocks == 0) { printk(KERN_ERR "RAMDISK: could not determine device size/n"); goto done; } printk(KERN_NOTICE "RAMDISK: Loading %d blocks [%d disk%s] into ram disk... ", nblocks, ((nblocks-1)/devblocks)+1, nblocks>devblocks ? "s" : ""); for (i=0; i < nblocks; i++) { if (i && (i % devblocks == 0)) { printk("done disk #%d./n", i/devblocks); rotate = 0; invalidate_buffers(device); 使輸入盤設備緩沖區無效 if (infile.f_op->release) infile.f_op->release(inode, &infile); printk("Please insert disk #%d and press ENTER/n", i/devblocks+1); wait_for_keypress(); if (blkdev_open(inode, &infile) != 0) { printk("Error opening disk./n"); goto done; } infile.f_pos = 0; printk("Loading disk #%d... ", i/devblocks+1); } infile.f_op->read(&infile, buf, BLOCK_SIZE, &infile.f_pos); outfile.f_op->write(&outfile, buf, BLOCK_SIZE, &outfile.f_pos);#if !defined(CONFIG_ARCH_S390) if (!(i % 16)) { printk("%c/b", rotator[rotate & 0x3]); rotate++; }#endif } printk("done./n"); kfree(buf);successful_load: invalidate_buffers(device); ROOT_DEV = MKDEV(MAJOR_NR, unit); 將根盤設備設置為當前載入的內存檔 if (ROOT_DEVICE_NAME != NULL) strcpy (ROOT_DEVICE_NAME, "rd/0");done: if (infile.f_op->release) infile.f_op->release(inode, &infile); set_fs(fs); return;free_inodes: /* free inodes on error */ iput(out_inode); blkdev_put(inode->i_bdev, BDEV_FILE);free_inode: iput(inode);}int __init identify_ramdisk_image(kdev_t device, struct file *fp, int start_block){ const int size = 512; struct minix_super_block *minixsb; struct ext2_super_block *ext2sb; struct romfs_super_block *romfsb; int nblocks = -1; unsigned char *buf; buf = kmalloc(size, GFP_KERNEL); if (buf == 0) return -1; minixsb = (struct minix_super_block *) buf; ext2sb = (struct ext2_super_block *) buf; romfsb = (struct romfs_super_block *) buf; memset(buf, 0xe5, size); /* * Read block 0 to test for gzipped kernel */ if (fp->f_op->llseek) fp->f_op->llseek(fp, start_block * BLOCK_SIZE, 0); fp->f_pos = start_block * BLOCK_SIZE; fp->f_op->read(fp, buf, size, &fp->f_pos); ; 讀取offset開始的512位元組 /* * If it matches the gzip magic numbers, return -1 */ if (buf[0] == 037 && ((buf[1] == 0213) || (buf[1] == 0236))) { printk(KERN_NOTICE "RAMDISK: Compressed image found at block %d/n", start_block); nblocks = 0; goto done; } /* romfs is at block zero too */ if (romfsb->word0 == ROMSB_WORD0 && romfsb->word1 == ROMSB_WORD1) { printk(KERN_NOTICE "RAMDISK: romfs filesystem found at block %d/n", start_block); nblocks = (ntohl(romfsb->size)+BLOCK_SIZE-1)>>BLOCK_SIZE_BITS; goto done; } /* * Read block 1 to test for minix and ext2 superblock */ if (fp->f_op->llseek) fp->f_op->llseek(fp, (start_block+1) * BLOCK_SIZE, 0); fp->f_pos = (start_block+1) * BLOCK_SIZE; fp->f_op->read(fp, buf, size, &fp->f_pos); /* Try minix */ if (minixsb->s_magic == MINIX_SUPER_MAGIC || minixsb->s_magic == MINIX_SUPER_MAGIC2) { printk(KERN_NOTICE "RAMDISK: Minix filesystem found at block %d/n", start_block); nblocks = minixsb->s_nzones << minixsb->s_log_zone_size; goto done; } /* Try ext2 */ if (ext2sb->s_magic == cpu_to_le16(EXT2_SUPER_MAGIC)) { printk(KERN_NOTICE "RAMDISK: ext2 filesystem found at block %d/n", start_block); nblocks = le32_to_cpu(ext2sb->s_blocks_count); goto done; } printk(KERN_NOTICE "RAMDISK: Couldn't find valid RAM disk image starting at %d./n", start_block);done: if (fp->f_op->llseek) fp->f_op->llseek(fp, start_block * BLOCK_SIZE, 0); fp->f_pos = start_block * BLOCK_SIZE; kfree(buf); return nblocks;}; fs/super.cvoid __init mount_root(void){ struct file_system_type * fs_type; struct super_block * sb; struct vfsmount *vfsmnt; struct block_device *bdev = NULL; mode_t mode; int retval; void *handle; char path[64]; int path_start = -1;#ifdef CONFIG_BLK_DEV_FD if (MAJOR(ROOT_DEV) == FLOPPY_MAJOR) { 當根盤還是軟盤,表示沒有載入過內存檔#ifdef CONFIG_BLK_DEV_RAM extern int rd_doload; extern void rd_load_secondary(void);#endif floppy_eject();#ifndef CONFIG_BLK_DEV_RAM printk(KERN_NOTICE "(Warning, this kernel has no ramdisk support)/n");#else /* rd_doload is 2 for a al initrd/ramload setup */ ; 只有當載入了initrd但沒有釋放到內存檔中(mount_inird=0)才有可能到這一步 if(rd_doload==2) rd_load_secondary(); 載入另一張軟盤到1號內存檔作為根盤 else#endif { printk(KERN_NOTICE "VFS: Insert root floppy and press ENTER/n"); wait_for_keypress(); } }#endif devfs_make_root (root_device_name); handle = devfs_find_handle (NULL, ROOT_DEVICE_NAME, MAJOR (ROOT_DEV), MINOR (ROOT_DEV), DEVFS_SPECIAL_BLK, 1); if (handle) /* Sigh: bd*() functions only paper over the cracks */ { unsigned major, minor; devfs_get_maj_min (handle, &major, &minor); ROOT_DEV = MKDEV (major, minor); } /* * Probably pure paranoia, but I'm less than happy about delving into * devfs crap and checking it right now. Later. */ if (!ROOT_DEV) panic("I have no root and I want to scream"); bdev = bdget(kdev_t_to_nr(ROOT_DEV)); if (!bdev) panic(__FUNCTION__ ": unable to allocate root device"); bdev->bd_op = devfs_get_ops (handle); path_start = devfs_generate_path (handle, path + 5, sizeof (path) - 5); mode = FMODE_READ; if (!(root_mountflags & MS_RDONLY)) mode |= FMODE_WRITE; retval = blkdev_get(bdev, mode, 0, BDEV_FS); if (retval == -EROFS) { root_mountflags |= MS_RDONLY; retval = blkdev_get(bdev, FMODE_READ, 0, BDEV_FS); } if (retval) { /* * Allow the user to distinguish between failed open * and bad superblock on root device. */ printk ("VFS: Cannot open root device /"%s/" or %s/n", root_device_name, kdevname (ROOT_DEV)); printk ("Please append a correct /"root=/" boot option/n"); panic("VFS: Unable to mount root fs on %s", kdevname(ROOT_DEV)); } check_disk_change(ROOT_DEV); sb = get_super(ROOT_DEV); 取根盤的超級塊 if (sb) { fs_type = sb->s_type; goto mount_it; } read_lock(&file_systems_lock); for (fs_type = file_systems ; fs_type ; fs_type = fs_type->next) { if (!(fs_type->fs_flags & FS_REQUIRES_DEV)) continue; 根文件系統必須依賴於塊設備 if (!try_inc_mod_count(fs_type->owner)) continue; 當文件系統模塊正在刪除過程中 read_unlock(&file_systems_lock); sb = read_super(ROOT_DEV,bdev,fs_type,root_mountflags,NULL,1);建立根盤的超級塊結構 if (sb) goto mount_it; read_lock(&file_systems_lock); put_filesystem(fs_type); 釋放對文件系統模塊的引用 } read_unlock(&file_systems_lock); panic("VFS: Unable to mount root fs on %s", kdevname(ROOT_DEV));mount_it: printk ("VFS: Mounted root (%s filesystem)%s./n", fs_type->name, (sb->s_flags & MS_RDONLY) ? " readonly" : ""); if (path_start >= 0) { devfs_mk_symlink (NULL, "root", DEVFS_FL_DEFAULT, path + 5 + path_start, NULL, NULL); memcpy (path + path_start, "/dev/", 5); vfsmnt = add_vfsmnt(NULL, sb->s_root, path + path_start); } else vfsmnt = add_vfsmnt(NULL, sb->s_root, "/dev/root"); 建立根盤的安裝結構 /* FIXME: if something will try to umount us right now... */ if (vfsmnt) { set_fs_root(current->fs, vfsmnt, sb->s_root); 設置當前進程的根盤和根目錄 set_fs_pwd(current->fs, vfsmnt, sb->s_root); 設置當前進程的當前盤和當前目錄 if (bdev) bdput(bdev); /* sb holds a reference */ return; } panic("VFS: add_vfsmnt failed for root fs");}#ifdef CONFIG_BLK_DEV_INITRDint __init change_root(kdev_t new_root_dev,const char *put_old){ 以new_root_dev作為根盤重新安裝根文件系統,原來的根轉移到put_old目錄下 struct vfsmount *old_rootmnt; struct nameidata devfs_nd, nd; int error = 0; read_lock(¤t->fs->lock); old_rootmnt = mntget(current->fs->rootmnt); 取當前進程的根盤安裝結構 read_unlock(¤t->fs->lock); /* First unmount devfs if mounted */ if (path_init("/dev", LOOKUP_FOLLOW|LOOKUP_POSITIVE, &devfs_nd)) error = path_walk("/dev", &devfs_nd); if (!error) { if (devfs_nd.mnt->mnt_sb->s_magic == DEVFS_SUPER_MAGIC && devfs_nd.dentry == devfs_nd.mnt->mnt_root) { dput(devfs_nd.dentry); down(&mount_sem); /* puts devfs_nd.mnt */ do_umount(devfs_nd.mnt, 0, 0); up(&mount_sem); } else path_release(&devfs_nd); } ROOT_DEV = new_root_dev; mount_root(); 改變根盤設備重新安裝根文件系統#if 1 shrink_dcache(); 清除目錄項緩沖中所有自由的目錄項 printk("change_root: old root has d_count=%d/n", atomic_read(&old_rootmnt->mnt_root->d_count));#endif mount_devfs_fs (); /* * Get the new mount directory */ error = 0; if (path_init(put_old, LOOKUP_FOLLOW|LOOKUP_POSITIVE|LOOKUP_DIRECTORY, &nd)) error = path_walk(put_old, &nd); 在新的根盤中尋找put_old目錄 if (error) { int blivet; printk(KERN_NOTICE "Trying to unmount old root ... "); blivet = do_umount(old_rootmnt, 1, 0); 卸載原始的根盤 if (!blivet) { printk("okay/n"); return 0; } printk(KERN_ERR "error %d/n", blivet); return error; } /* FIXME: we should hold i_zombie on nd.dentry */ move_vfsmnt(old_rootmnt, nd.dentry, nd.mnt, "/dev/root.old"); mntput(old_rootmnt); path_release(&nd); return 0;}#endifstatic struct vfsmount *add_vfsmnt(struct nameidata *nd, 在虛擬文件系統中的安裝點 struct dentry *root, 安裝盤的根目錄項 const char *dev_name) 安裝盤名稱{ struct vfsmount *mnt;
————————————————
版權聲明:本文為CSDN博主「huanghaibin」的原創文章,遵循 CC 4.0 BY-SA 版權協議,轉載請附上原文出處鏈接及本聲明。
原文鏈接:https://blog.csdn.net/huanghaibin/java/article/details/478215

『陸』 linux 內核編譯需要多少空間

配置內核
有了要編譯配置的內核,先來介紹怎麼樣配置內核。具體的步驟分為一下幾 步:
1.在開始配置內核之前,首先需要通過下面的命令清除所有的臨時文件、中間件和配置文件。對於一個剛從網 上下載的內核來說,它肯定是干凈的,這么做只會多此一舉。但是這是一個良好習慣,而且不會有壞結果。

#make mrproper

2. 然後 要了解自己系統的硬體配置情況,比如CPU的類型、主辦晶元、顯卡和音效卡的型號等。
3. 配置 內核選項,用到的命令是:

#make

用到的配置工具有:
◆ config 基於互動式的文本配置界面。每個問題以線形格式出現,並被一個一個地回答,而且一旦作出了回答就不能再修改 了。
◆ oldconfig 同config相似,但是使用原有的配置文件, 而且只會提問有關新內核特性的問題,對於內核升級很方便。
◆ menuconfig 一個文本模式、選單驅動的配置界面。
◆ xconfig 基於Tcl/Tk的X圖形配置界面。
現在開始配置內核,使用的工具為menuconfig。在命令行模式下執行下面的命 令:

#make menuconfig

在閃過幾行字之後就出現內核配置界面。
使用方向鍵在各選項間移動;使用「Enter」鍵進入下一層選單;每個選項上的 高亮字母是鍵盤快捷方式,使用它可以快速地到達想要設置的選單項。在括弧中按「y」將這個項目編譯進內核中,按「m」編譯為模塊,按「n」為不選擇(按空格鍵也可在編譯進 內核、編譯為模塊和不編譯三者間進行切換),按「h」將顯示這個選項的幫助信息,按「Esc」鍵將返回到上層選單。
注 意,如果「make menuconfig」命令失敗,很可能是ncurses庫沒有安裝。

『柒』 linux編譯內核時,到安裝內核模塊:#make moles_install 時,過程中提示設備上沒有空間

建議裁剪內核,內核中很多驅動模塊,子系統等一般用戶都用不上,我在我自己的電腦上裁剪後編譯的內核源碼樹大小隻有700多M~

『捌』 關於ubuntu內核編譯的問題

解決辦法 修改 menu.lst 將 root=/UUIDxxxxxxx 這個改為 root=/dev/sdax
另外 從Filesystem type is ntfs.partition type 0x07 這一行我大概可看出,你是wubi安裝的, 這種情況 我建議你重新編譯內核並生成initrd, 因為內核不支持uuid的,initrd才支持,如果把filesystem編譯進內核了,啟動不用initrd.img的話,就只能用root=/dev/sdax的參數作為內核引導參數…

所以關鍵在於 一定要打開initrd支持並生成initrd

至於具體在那裡,我這邊環境所限無法告知, 麻煩你自己在make menuconfig裡面仔細看看或者google一下

/dev/sdxx 是你的硬碟的/的設備名稱 可以用正常啟動的內核引導後 輸入sudo df -h或者 sudo fdisk -l

目前的機器來講 編譯20分鍾很正常, 我的內核優化的很小 大概十分鍾左右就編譯完了 .

另外 內核源碼解開後會佔用接近200M的空間, 而gcc編譯內核和大型軟體時候產生的臨時文件佔用好幾百M乃至上G是很常見的的, 可以進入源代碼文件夾運行 make clean && make mrproper 來清理一下

『玖』 在LINUX中可否把應用程序都編譯到內核中,讓系統啟動後完全在內存中運行不讀硬碟!

不行,
內核是內核,只提供最基本的服務。很多服務可以編譯成模塊裝入內核,但是模塊也不是無限多的。你編譯過內核嗎?內核文件不大,解壓出來有200多M吧,如果全部功能編譯的話,一般電腦沒有幾天可能下不來。
把程序編譯到內核,不是不行,不過你的程序要修改。如果你能為linux內核提供代碼的水平,估計離你說的就不遠了。
你的想法有點...... 在你硬碟上讀點東西就那麼吝嗇嗎?
我Linux4G多的文件,分了6G數據空間,還有2G的交換文件,我都沒心疼。

閱讀全文

與編譯內核空間相關的資料

熱點內容
安卓怎麼用支付寶交違章罰款 瀏覽:665
php面向對象的程序設計 瀏覽:504
數據挖掘演算法書籍推薦 瀏覽:894
投訴聯通用什麼app 瀏覽:150
web伺服器變更ip地址 瀏覽:954
java正則表達式驗證郵箱 瀏覽:360
成熟商務男裝下載什麼軟體app 瀏覽:609
加密2h代表長度是多少厘米 瀏覽:23
拍賣程序員 瀏覽:101
電腦的圖片放在哪個文件夾 瀏覽:274
unsignedintjava 瀏覽:216
編譯器下載地址 瀏覽:42
什麼是面對對象編程 瀏覽:708
b站伺服器什麼時候恢復 瀏覽:721
6p相當於安卓機什麼水準 瀏覽:498
能否給隱藏相冊加密 瀏覽:597
糖心app改什麼名 瀏覽:824
戰地1控伺服器如何部署 瀏覽:396
xp還原系統輸入命令 瀏覽:324
mysql命令行版本 瀏覽:305